1

I would like to have a page break before the table of contents when knitting. Right now it displays the table of contents right after the title (first) page, which is not aesthetically pleasing.

SteveMcManaman
  • 391
  • 1
  • 17
  • Does this answer your question? [How can I control the location of the table of contents in R Markdown (PDF output)?](https://stackoverflow.com/questions/68942638/how-can-i-control-the-location-of-the-table-of-contents-in-r-markdown-pdf-outpu) – manro Oct 24 '21 at 13:43
  • Or maybe [this question](https://stackoverflow.com/questions/30972442/how-to-separate-title-page-and-table-of-content-page-from-knitr-rmarkdown-pdf)? – Ben Oct 24 '21 at 13:44
  • @Ben Thanks, but I tried this example, but it generates multiple LaTeX files and needs manual changes in the .tex file. I only need the pdf output. – SteveMcManaman Oct 24 '21 at 14:04
  • @manro I downloaded the default.tex file and placed it in the rmd directory as suggested. Can you help me with where to exactly place that blank page in the default template? Right now I get error messages for execution. p.s. I don't know LaTeX very much, maybe that's why I'm confused. – SteveMcManaman Oct 24 '21 at 14:18
  • 1
    @Safa Add what you did in the question's body. Code from .rmd – manro Oct 24 '21 at 14:20

1 Answers1

1

The most easiest solution for you - changing documentclass to report (table of contents will be on the second page).

---
title: "test"

header-includes: 
 \usepackage{geometry}
 \geometry{top=0.75in,left=3in,bottom=0.75in,right=0.80in}

output:
  pdf_document:
    toc: true
    number_sections: true
documentclass: report   
---

\chapter{First}

\chapter{Second}
manro
  • 3,529
  • 2
  • 9
  • 22
  • It's very straightforward; however, it changes the page margins and distorts the structure to some extent. Can we somehow increase the margins in each page here? – SteveMcManaman Nov 05 '21 at 11:48
  • @Safa yes, we can. You want a different margin on the every page? Or one margin for the all body of document? – manro Nov 05 '21 at 12:03
  • One standard margin, like it was before adding the `documentclass: report` would be great. @manro – SteveMcManaman Nov 05 '21 at 15:08
  • @Safa I added above, look. If i helped, you can accept my answer ;) – manro Nov 05 '21 at 15:33