Reputation: 115
The YAML header:
---
subtitle: "subtitle"
title: "title"
output:
pdf_document:
toc: true
toc_depth: 2
number_sections: true
---
This places the table of contents at the very beginning of the document but I would like to have it after the two first pages.
Does anyone know how to manage this? I would prefer not to use too much LaTeX.
Upvotes: 4
Views: 2292
Reputation: 14957
If the first two pages shoud contain static content (not generated in the body of the R Markdown document), then moving the table of contents to page 3 can be achieved with small modifications in the LaTeX template used by Pandoc.
As explained in The Cookbook, the default LaTeX template is this (latest version).
Download that file and save it in the directory of your RMD file. In my example below I named the file toc-at-page3-template.tex
.
Edit the template: For example, after line 476 (i.e., before $if(toc)$
), add
\begin{center}
Custom Stuff
\end{center}
\clearpage
\begin{center}
More Custom Stuff
\end{center}
\clearpage
In your RMD file, enable the custom template:
output:
pdf_document:
toc: true
template: toc-at-page3-template.tex
---
Foo.
Output: (click on thumbnails to enlarge)
Upvotes: 5