[英]How can I control the location of the table of contents in R Markdown (PDF output)?
YAML 标头:
---
subtitle: "subtitle"
title: "title"
output:
pdf_document:
toc: true
toc_depth: 2
number_sections: true
---
这会将目录放在文档的最开头,但我希望将其放在前两页之后。
有谁知道如何管理这个? 我不想使用太多的 LaTeX。
如果前两页应该包含静态内容(不是在 R Markdown 文档的正文中生成的),则可以通过对 Pandoc 使用的 LaTeX 模板进行一些小的修改来将目录移动到第 3 页。
如The Cookbook中所述,默认的 LaTeX 模板是这个( 最新版本)。
下载该文件并将其保存在 RMD 文件的目录中。 在下面的示例中,我将文件命名为toc-at-page3-template.tex
。
编辑模板:例如,在第 476 行之后(即在$if(toc)$
),添加
\\begin{center} Custom Stuff \\end{center} \\clearpage \\begin{center} More Custom Stuff \\end{center} \\clearpage
在您的 RMD 文件中,启用自定义模板:
output: pdf_document: toc: true template: toc-at-page3-template.tex --- Foo.
输出:(点击缩略图放大)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.