jgm/pandoc — Issue #424: PDF TOC page numbering off by sizeof(TOC)
Author: elliottslaughter
Created: 2012-02-19 19:08:48+00:00
State: open

The page numbering in Pandoc's PDF generation (via LaTeX) seems to be off by the number of pages in the Table of Contents.

Take, for example, the following file, and name it test.md:

https://gist.github.com/1865198

And generate a PDF with the command:

pandoc -o test.pdf --standalone --toc test.md

The resulting PDF will have all the pages in the TOC off-by-1. That is, Section A is marked as starting on page 1 even though it starts on page 2, etc.

Furthermore, my tests indicate that this is not a simple off-by-1, as the gap grows with the size of the table of contents. If the table of contents is N pages long, the page numbers will all of off by N.

I believe fixing this requires running LaTeX a third time (rather than just two times). The first time, there is no TOC file, so LaTeX doesn't produce a TOC in the PDF output, but does create a reference TOC file for the next run. The second time, LaTeX inserts a TOC into the PDF file, but the pages are off because the first run had no TOC file. A third run is required to get the correct page numbers into the PDF file.

Hope this helps.