pgf
pgf copied to clipboard
pgfpages: page numbers with the resize to layout
The manual says:
Another word of caution: using pgfpages will produce wrong page numbers in the .aux file. The reason is that TEX instantiates the page numbers when writing an .aux file only when the physical page is shipped out.
However, this is rather minimal and I imagine that in some cases the page numbering can be made to work correctly. Consider the following example:
\documentclass[a4paper]{article}
\usepackage{pgfpages}
\pgfpagesuselayout{resize to}[physical paper height=240mm,
physical paper width=170mm]
\begin{document}
\tableofcontents
\section{Section}
\end{document}
This puts Section on page 1, but lists it as starting on page 2 in the table of contents. In fact, any reference to a page number in a document that uses the resize to
layout will be 1 too high.
A similar behavior is reported in https://tex.stackexchange.com/questions/480701/final-year-thesis-toc-offset-by-1
Would it be very hard to fix this off-by-one error? If so, can someone explain why (maybe also in the manual)? The issue is a bit tricky, because it is not noticed on first glance when looking at the document.
From what I understand, this is also what causes beamers show notes on second screen
to produce incorrect page numbers. See josephwright/beamer#228 and What is going on with pgfpages and page labels?.
This is slightly more annoying than an off-by-one error as all pages numbers are now used on 2 successive pages, so instead of being number 1, 2, 3, etc. the PDF now has labels 1, 1, 2, 2, 3, 3, and so on.
Note that the linked texlive question contains a patch which may fix the issue − or at least did in 2013.