I'm using org-mode to export to PDF. I'm going over the same document multiple times and exporting different branches during my evaluation.

I always want the first section in the PDF to start on a clean page, regardless of which subtree I export. So, there should always be a cleanpage after the TOC.

I can manually add newpage everywhere in my org-mode doc, but I have a tree with thousands of branches. I'd rather add this in the latex preamble or .emacs config, once.

Is it possible?


Add the following to your init file:

(setq org-latex-toc-command "\\tableofcontents \\clearpage")

Explanation: The variable org-latex-toc-command normally is set to the value "\\tableofcontents" and its value is emitted by the LaTeX exporter into the output TeX file at the place where the TOC is to be placed (normally right after the \begin{document} in the TeX file):


When the TeX file is processed to produce the PDF output file, the LaTeX processor expands the \tablecontents macro to the full TOC.

By modifying the value of org-latex-toc-command, the LaTeX exporter is made to emit the modified string, so the TeX file looks liks this:

 \tableofcontents \clearpage

When the modified TeX file is processed by the LaTeX processor, after \tableofcontents is expanded to the full TOC, the \clearpage macro causes the page to be emitted immediately, leaving the rest of it blank.

Note BTW, that in an emacs string like "\\foo", the first backslash "escapes" the second, so that one backslash is part of the string. More about such escape sequences can be found in the Emacs documentation, e.g. here and here.

  • You might show the doc of that variable and make clear what that value does. That might be more helpful. – Drew Jul 13 '18 at 2:21
  • @Drew: Edited, PTAL. – NickD Jul 13 '18 at 2:54

Your Answer

