如何控制 table 内容在 R Markdown(PDF 输出)中的位置?

How can I control the location of the table of contents in R Markdown (PDF output)?

YAML header:

---
subtitle: "subtitle"
title: "title"
output: 
  pdf_document:
    toc: true
    toc_depth: 2
    number_sections: true
---

这会将 table 内容放在文档的最开头,但我想将它放在前两页之后。

有人知道如何管理吗?我宁愿不要使用太多 LaTeX。

如果前两页应该包含静态内容(不是在 R Markdown 文档的正文中生成的),那么将 table 的内容移动到第 3 页可以通过在 LaTeX 模板中进行小的修改来实现Pandoc 使用。

The Cookbook, the default LaTeX template is this (latest version 中所述。

  1. 下载该文件并将其保存在 RMD 文件的目录中。在下面的示例中,我将文件命名为 toc-at-page3-template.tex.

  2. 编辑模板:例如在第476行之后(即$if(toc)$之前),添加

     \begin{center}
     Custom Stuff
     \end{center}
    
     \clearpage
    
     \begin{center}
     More Custom Stuff
     \end{center}
    
     \clearpage
    
  3. 在您的 RMD 文件中,启用自定义模板:


     output:
       pdf_document:
         toc: true
         template: toc-at-page3-template.tex
     ---
    
     Foo.
    

输出: (点击缩略图放大)