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!


\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}}



\frame{hi \note{\pg{2}}}

\frame{there \note{\pg{3}}}

\frame{how \pause are \pause you \pause today


Here’s what the output looks like:

enter image description here

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?

  • 1
    As a hack until a proper fix/workaround is found, how about using \documentclass[hyperref={pdfpagelabels=false}]{beamer}, so then the PDF viewer has to display the actual page numbers rather than the one pgfpages appears to use. Commented Jan 7, 2013 at 0:31

2 Answers 2


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 the hyperref 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 the hyperref package (like page transition) are already set for the next logical page when the (previous) physical page is shipped, which results in the wrong pdfpagelabels 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 after hyperref since hyperref's shipout hook may only be called for physical pages.

% Save and restore pdfpage related information for hyperref.

  % Create new counter to save the page counter.

  % The special per-page label 'thispdfpagelabel' is set/cleared
  % globally during hyperref's shipout hook for physical pages.
  % Therefore it must be saved temporarily before physical shipout.
      % \HyPL@thisLabel is only defined if pdfpagelabels are activated.

  % Save all relevant page states if the first logical page is shipped.
    % Probably it should be configurable which logical page is
    % considered, but the first page seems reasonable for now.
      % Save the special per-page label 'thispdfpagelabel', which is
      % temporarily saved before.
      % Save the page counter and its formatting.
      % Save the page transition and duration.

  % Restore all relevant page states.
    % Restore the special per-page label 'thispdfpagelabel'.
      % \HyPL@thisLabel is only defined if pdfpagelabels are activated.
    % Restore the page counter and its formatting.
    % Restore the page transition and duration.

  % Do nothing if hyperref is not loaded.

% "Patch" macros of pgfpages.

    \let \protect \noexpand
    % Restore page states before physical shipout:
      \vbox to \pgfphysicalheight{%

  % Temporarily save some page states which are globally set during
  % physical shipout:
      \expandafter\global\expandafter\setbox\csname pgfpages@box@\the\pgf@shipoutnextto\endcsname=\box\voidb@x%
    \ifpgf@holdingphysicalpage% shipout physical page now
        \expandafter\global\expandafter\setbox\csname pgfpages@box@\the\pgf@currentshipout\endcsname=\box\voidb@x%

  % Save page states before logical shipout:
  \expandafter\global\expandafter\setbox\csname pgfpages@box@#1\endcsname=}
  • On my system (also with TeXLive 2012) I get the frame numbers as page numbers in the viewer: 1,2,3,3,3,3. Since I get the same numbers without \usepackage{pgfpages} and \setbeameroption, I would consider this the expected behaviour. Did you want to achieve something else? Commented Jun 9, 2013 at 19:27
  • My apologies, this question was from so long ago that I forgot what it was asking. You did indeed explain the cause of the problem and provide a good solution. Thank you!
    – andrew
    Commented Jun 9, 2013 at 19:41
  • Has anybody else gotten this to work? On my system, this causes pdflatex to just churn (i.e., it occupies CPU time but does not return).
    – mako
    Commented May 27, 2014 at 21:46
  • How should one use the code above to fix the problem? Commented Nov 8, 2018 at 23:16

Redefine the command pgfpagescurrentpagewillbelogicalpage and beamer@outsideframenote in the preamble to make the pdf page label same with the frame label:



Also see https://github.com/josephwright/beamer/issues/807#issuecomment-2102101959

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .