【问题标题】:How to add list of figures and list of tables to the table of content with R markdown and bookdown如何使用 R markdown 和 bookdown 将图形列表和表格列表添加到目录中
【发布时间】:2019-06-17 19:44:38
【问题描述】:

我有一份报告(pdf 输出),我想在其中将参考书目、图表列表和表格列表添加到附录中。我希望这三个元素出现在目录中。

我通过将bibliography: bibliography.bib 添加到我的 yaml 标头来添加 参考书目。我直接用 LaTex 添加的图形列表和表格列表。

因此,我的附录看起来像:

# Literature {-}

\listoffigures

\listoftables

几乎有效:参考书目、图表列表和表格列表正确呈现。

唯一的问题是,目录只显示一个条目文学。图表列表和表格列表不显示。

我该如何解决这个问题?


我尝试在 yaml 标头的各个位置使用 lof: yeslot: yes(想法来自 here 以及 toc_appendix: yes(来自同一来源)

我错过了什么?


我的完整标题如下所示:

---
title: something
header-includes: \usepackage{graphicx} \usepackage{float} \usepackage{xcolor} \usepackage{framed} \usepackage{longtable} \definecolor{shadecolor}{RGB}{240,240,240} \pagenumbering{roman} \usepackage{caption} \captionsetup{font=footnotesize}
output:
  bookdown::pdf_book:
    fig_caption: yes
    highlight: kate
    number_sections: yes
    toc: yes
date: | 
    |  
    | `r format(Sys.time(), '%B %d, %Y')`
documentclass: report
geometry: margin=1in
fontfamily: mathpazo
fontsize: 11pt
bibliography: bibliography.bib
preamble: |
  % Any extra latex you need in the preamble
---

【问题讨论】:

  • 在自己的行中使用 --- output: bookdown::pdf_document2 toc: yes lof: yes lot: yes --- 和每个参数对我来说效果很好。
  • @MartinSchmelzer:谢谢您的回复。那也是我的第一次尝试。奇怪的是我收到一个错误:Error in base_format(toc = toc, number_sections = number_sections, fig_caption = fig_caption, : unused arguments (lof = TRUE, lot = TRUE)。你知道可能是什么问题吗?
  • @MartinSchmelzer:为了完整起见,我添加了标题。我尝试在toc: yes 下方插入lof: yeslot: yes,但没有成功。我也将pdf_book 更改为pdf_document2,但没有成功。
  • @MartinSchmelzer 奇怪,我可以重现错误。看起来像一个错误?
  • 问题出在文档类上。如果您删除此行,它会起作用。如果您需要使用报表文档类,请将\usepackage[nottoc]{tocbibind} 添加到您的包含中。

标签: r markdown r-markdown bookdown


【解决方案1】:

问题在于文档类报告。我猜它不像 article 类那样处理表格列表或图形列表。

一个简单的解决方案是将\usepackage[nottoc]{tocbibind} 添加到您的文档中。该软件包完全符合您的要求 - 它将两个附录部分添加到您的目录中。您仍然需要使用 \listoffigures\listoftables 在文档末尾手动添加它们。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-19
    • 2017-07-14
    • 1970-01-01
    • 2017-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多