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

If you don't want to permanently change the value of org-latex-toc-command (as per @NickD answer), you can also include a latex export block before the first section

#+begin_export latex
  \clearpage \tableofcontents \clearpage

* Fist section

Remember to include #+OPTIONS: toc:nil in the preamble to avoid a double TOC

  • 1
    This can also be done with file variables. Put this as the first line: #+COMMENT:-*- org-latex-toc-command: "\\tableofcontents \\clearpage" -*-. gnu.org/software/emacs/manual/html_node/emacs/… – Lorem Ipsum Apr 25 '20 at 1:33
  • @@latex:\clearpage@@ before main text should work as well. Also, it doesn't need #+OPTIONS: toc:nil. – grepcake Jul 5 '20 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.