# Reliable cross-reference to a frame in beamer

I make extensive use of beamer's overlay mechanism to build animations. Depending on the audience, but especially for the handout version, I then use frame-level overlay specifications to select the steps of the animation (i.e., slides of the frame) to be actually shown:

\begin{frame}<handout:2,4>[label=otherframe]{Other Frame}
\begin{itemize}[<all:+->]
\item First Item
\item Second Item -- this step also to be shown in handout mode
\item Third Item
\item Forth Item  -- this step also to be shown in handout mode
\end{itemize}
\end{frame}


This causes an issue when cross-referencing to such a frame with \ref{otherframe}. If the label=otherframe option is passed, beamer generates a label for each slide of the frame (otherframe<1>, otherframe<2>, ...) and additionally the label otherframe as an alias to otherframe<1>. However, depending on the frame-level overlay specification, slide 1 might not be part of the deck, so the reference could not be resolved.

Of course, I could write \ref{otherframe<2>} in handout mode instead, but this would be bad separation of concerns. Given the multiple modes (beamer, handout), reference management would become a nightmare. The decision which steps of the animation to show should remain independent from how to refer to it as a whole.

I consider this as a bug in beamer: IMHO, otherframe should refer to the first actually available slide of the frame – which not always is otherframe<1>.

I am looking for suggestions and workarounds.

Complete MWE:

% \documentclass[beamer]{beamer}
\documentclass[handout]{beamer}

\begin{document}

\begin{frame}<handout:2,4>[label=otherframe]{Other Frame}
\begin{itemize}[<all:+->]
\item First Item
\item Second Item -- this step also to be shown in handout mode
\item Third Item
\item Forth Item  -- this step also to be shown in handout mode
\end{itemize}
\end{frame}

We have seen this on \ref{otherframe}! % not resolved in handout mode
\end{frame}

\end{document}

• If you place the label inside the frame \begin{frame}<handout:2,4>{Other Frame}\label{otherframe} it should always link to the first visible slide of your current mode. Disadvantages: This will cause "label already defined warnings" (but it should still work, because the first label is used) and you probably loose some functionality, e.g. \againframe does not work. – samcarter_is_at_topanswers.xyz Oct 19 '18 at 9:50
• @samcarter: Thanks, that is an easy to apply workaround (I always believed that with multiple definition warnings the last would win.) Would you mind turning your comment into an answer! – Daniel Oct 21 '18 at 19:41

Disclaimer: the following workaround is no solution and has a couple of disadvantages

If you bypass beamer owns frame-label mechanism and use \label{...} inside the frame, you'll get working links for your example.

Warnings:

• You won't be able to use beamer features like \againframe with this approach

• It will produce warnings about multiple defined labels, but because you want to use the first occurrence, this should be no problem in your specific case.

% \documentclass[beamer]{beamer}
\documentclass[handout]{beamer}

\begin{document}

\begin{frame}<handout:2,4>{Other Frame}
\label{otherframe}
\begin{itemize}[<all:+->]
\item First Item
\item Second Item -- this step also to be shown in handout mode
\item Third Item
\item Forth Item  -- this step also to be shown in handout mode
\end{itemize}
\end{frame}


• Thanks! I think the warnings read a bit over-cautiously, as one can use \label and beamer‘s label= option for the same frame (with different identifiers, of course). So in the end it is a couple of warnings and two labels for the frame, which is not ideal, but well-workable without unbearable side effects. – Daniel Oct 22 '18 at 6:53