I’m using a feature of beamer that shows notes beside slides, but the page numbers that are coming out are crazy, making it impossible to extract specific slides into other documents with \includegraphics[page=n]{presentation.pdf}
.
For example, in this MWE, there are two frames that are each 1 slide, and then one frame that is four slides. The PDF page labels that show up in Acrobat are, as indicated, 2, 3, 3, 3, 3, and 7. It starts at page 2 instead of 1, and then there are four page 3s, but they don’t even all belong to the same frame!
\documentclass{beamer}
\usepackage{pgfpages}
\setbeameroption{show notes on second screen=left}
\setbeamertemplate{note page}{frame \insertframenumber \\ \insertnote}
\def\pg#1{pgfpages says this is page #1 but it is really page \arabic{page}}
\begin{document}
\setcounter{page}{0}
\frame{hi \note{\pg{2}}}
\frame{there \note{\pg{3}}}
\frame{how \pause are \pause you \pause today
\note<1-3>{\pg{3}}
\note<4>{\pg{7}}}
\end{document}
Here’s what the output looks like:
I know that the manual says, “pgfpages will produce wrong page numbers in the .aux file” and gives a manual workaround. But the page
counter still works, so shouldn’t there be some way to pass that through to the PDF? I’d like to fix this, but don’t know where to start. Specifically, when the manual says that “TeX instantiates the page numbers when writing an .aux file only when the physical page is shipped out,” what exactly is it talking about? Where is the source code for that?
Best Answer
The page labels in the
.pdf
file are actually independent of the page numbers in the.aux
file. The page labels are also set during shipout but by thehyperref
package.The
pgfpages
package however ships out a physical page after the next/following logical page is finished. This is necessary for the 'two screens with optional second' layout to allow setting the second screen after the main screen. However, as a side effect, the page counter and some page states of thehyperref
package (like page transition) are already set for the next logical page when the (previous) physical page is shipped, which results in the wrongpdfpagelabels
and page transitions occurring too early.To solve this problem, the relevant page states can be saved when the first logical page of a physical page is to be shipped and restored before the corresponding physical page is shipped.
It should be noted that this all only works if
pgfpages
is loaded afterhyperref
sincehyperref
's shipout hook may only be called for physical pages.