# Issues

Issue #226 resolved

# Using labels and notes causes multiply defined labels

cyberSingularity
created an issue

If a frame/slide contains a \label (perhaps implicitly) and later uses \insertslideintonotes to recall that slide (typically done in notes pages), the label gets multiply defined. This, apart from generating a LaTeX warning, also makes the labels point to the pages that contain the last respective use of \insertslideintonotes instead of the original slide where the label was defined.

This issue was reported on TeX.SX at http://tex.stackexchange.com/q/80530/17427 and a suggested fix was posted (by myself) as an answer. I enclose a similar (smaller) MWE and fix here:

MWE (note the warnings in the log file, the multiple \newlabels in the aux file and the incorrect referencing behaviour):

\documentclass{beamer}
\setbeameroption{show notes}

\begin{document}

\begin{frame}[label=myframe]{Frame Title}
The Huge text after the colon should say 1 (on this slide and in the notes), as I am referring to the page number of the current slide: {\Huge\getpagerefnumber{myframe}}.
\note{But if the slide has a notes page, both say 2. The issue is caused by multiply defined labels, as the label is repeated when re-using the box for the notes slide. Examine the aux file!}
\end{frame}
\end{document}


Fix (essentially suggested as an answer on this other TeX.SX question: http://tex.stackexchange.com/q/82250/17427): Wrap the copy of the slide box in \leaders so future times when it is recalled, TeX does not reprocess the \write nodes stored in the box, which correspond to the labels. I believe this to be a robust solution. The following patches \beamer@framenotesend to add the code to wrap the copied box in \leaders (included in the MWE to illustrate that it works), and I propose that this fix could be incorporated directly into beamer:

\documentclass{beamer}
\setbeameroption{show notes}

%%% begin patch
\usepackage{etoolbox}
\makeatletter
\patchcmd\beamer@framenotesend{\global\setbox\beamer@frameboxcopy=\copy\beamer@framebox}{%
\global\setbox\beamer@frameboxcopy=\copy\beamer@framebox
\global\setbox\beamer@frameboxcopy=\hbox{\leaders\copy\beamer@frameboxcopy\hskip\wd\beamer@frameboxcopy}%from Stephan Lehmke's comment on http://tex.stackexchange.com/q/82250/17427
}{}{\showtokens{failed to patch \beamer@framenotesend}}
\makeatother
%%% end patch

\begin{document}

\begin{frame}[label=myframe]{Frame Title}
The Huge text after the colon should say 1 (on this slide and in the notes), as I am referring to the page number of the current slide: {\Huge\getpagerefnumber{myframe}}.
\note{But if the slide has a notes page, both say 2. The issue is caused by multiply defined labels, as the label is repeated when re-using the box for the notes slide. Examine the aux file!}
\end{frame}
\end{document}