josephwright / beamer

A LaTeX class for producing presentations and slides
Other
1.35k stars 139 forks source link

wrong page labels when using \pause and \setbeameroption{show notes on second screen} #807

Open rndblnch opened 1 year ago

rndblnch commented 1 year ago

the labels of pages are messed-up when using \pause in a frame in conjunction with \setbeameroption{show notes on second screen}. minimal sample below:

\documentclass{beamer}
\setbeameroption{show notes on second screen}
\setbeamertemplate{footline}[frame number]

\begin{document}
    \begin{frame}
        \begin{itemize}
        \item 1
        \end{itemize}
    \end{frame}
    \begin{frame}
        \begin{itemize}
        \item 2
        \pause
        \item 3
        \end{itemize}
    \end{frame}
\end{document}

opening the resulting document show that even if the frame number is right (see bottom right of the pages), the pdf label is wrong (see 1 instead of 2 for the second page in the thumbnails sidebar)

Screenshot 2022-11-29 at 23 28 19

this matters because page labels are used by presenter tools to detect frames.

tgbugs commented 1 year ago

On 3.63 and 3.68 I see a similar issue when using evince to view. I am not using \pause anywhere that is visible in the source tex file.

\setbeameroption{show notes on second screen=right}

producing 2022-12-08-223010-snip and

\setbeameroption{show notes}

producing 2022-12-08-223302-snip

rndblnch commented 1 year ago

I tried to resolve this by myself, but my knowledge of beamer internals is weak. commenting this line: https://github.com/josephwright/beamer/blob/main/base/beamerbasenotes.sty#L110 solves this issue for the minimal example I reported, but produce even weirder result for more complex cases (e.g. producing this labels 1, 2, 2, 4, 2, 6, 3 where i should get 1, 2, 2, 3, 3, 3, 4 for a doc with 4 frames having 1, 2, 3 and 1 steps)

knowledge of how pgfpages works looks necessary to dig into that …

lrtfm commented 2 months ago

Workaround

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

\makeatletter
\ltx@ifpackageloaded{pgfpages}{%
  \let\old@pgfpagescurrentpagewillbelogicalpage\pgfpagescurrentpagewillbelogicalpage
  \renewcommand\pgfpagescurrentpagewillbelogicalpage{%
    \renewcommand*{\HyPL@EveryPage}{\relax}%
    \old@pgfpagescurrentpagewillbelogicalpage}
}{}

\let\old@beamer@outsideframenote\beamer@outsideframenote
\renewcommand\beamer@outsideframenote{%
  \renewcommand*{\thepage}{\insertframenumber}%
  \old@beamer@outsideframenote}
\makeatother

Explanation

The pdf page label is added by the hyperref package. In every page, hyperref write out some page info to aux file using \HyPL@EveryPage and the pdf page label is set to \thepage.

  1. In the case with option show notes on second screen, adding the following line

    \renewcommand*{\HyPL@EveryPage}{\relax}%

    before the line \pgfpagescurrentpagewillbelogicalpage{2} in file beamerbasenotes.sty#L110 will disable writing page label information into the PDF file when outputting note slides.

  2. For the case with option show notes, set the macro \thepage

    \renewcommand*{\thepage}{\insertframenumber}

    in the definition of beamer@outsideframenote to make the note page label same as the frame number. or you can add a prefix for the note page like this

    
    \renewcommand*{\thepage}{notes-\insertframenumber}