1

In this thread, @diabonas taught me how to automate the process of passing an overlay number to \hypertarget in an itemize environment. The construction was \hypertarget<.>{label4}{\beamerbutton{something}} This works great, but only within an itemize or enumerate environment. When I try it outside of any environment, the <.> construction doesn't quite work. In the example below, when I click on the button in the second frame, it jumps back to the third line instead of the fourth, and the button is not displayed. Could somebody advise how to fix this please?

\documentclass{beamer}
\begin{document}
\begin{frame}[<+->]
First  \\
\pause
Second \\
\pause
Third \\
\pause
Fourth \hypertarget<.>{label4}{\beamerbutton{I'm on the fourth line}} \\
\pause
Fifth \\
\pause
Sixth \\
\end{frame}
\begin{frame}
\hyperlink{label4}{\beamerbutton{I jump to the fourth line of previous frame}}
\end{frame}
\end{document}
4

The counter used by \pause is beamerpauses, which is somewhat easier to use than the count beamer@minimum. Both work though.

\documentclass{beamer}
\makeatletter
\newcommand*{\overlaynumber}{\number\beamer@minimum}
\makeatother
\begin{document}
\begin{frame}[<+->]
First  \par
\pause
Second \par
\pause
Third \hypertarget<\overlaynumber>{label3}{\beamerbutton{I'm on the third line}} \par
\pause
Fourth \hypertarget<\thebeamerpauses>{label4}{\beamerbutton{I'm on the fourth line}} \par
\pause
Fifth \par
\pause
Sixth \par
\end{frame}
\begin{frame}
\hyperlink{label3}{\beamerbutton{I jump to the third line of previous frame}}\par
\hyperlink{label4}{\beamerbutton{I jump to the fourth line of previous frame}}\par
\end{frame}
\end{document}
  • I like using \beamer@minimum, as it works both inside and outside enumerate/itemize environments despite the different behaviour of the beamerpauses counter as analysed by Mike in his nice answer. It might have a few gotchas if you use complicated nested constructs involving \only and \pause (although I haven't encountered such cases in my experiments), but that's probably asking for trouble anyway ;) – diabonas Sep 22 '17 at 13:17
3

The counter beamerpause is incremented differently for \pause or list environments. Both, \pause and \item increment the counter. This leads to the counter being silde number + 1 in list environments. And since <.> is mainly for lists, it decreases the number. Using <.> with \pause therefore leads to <3> in your case, and thus not printing the button.

But an offset can be added (<.(1)>). This can be used to correct the error.

This code shows the behaviour and the fix:

\documentclass{beamer}
\makeatletter
\newcommand*{\overlaynumber}{\number\beamer@minimum}
\makeatother
\begin{document}
\begin{frame}[<+->]
First  (\thebeamerpauses) \\
\pause
Second (\thebeamerpauses) \\
\pause
Third  (\thebeamerpauses) \\
\pause
Fourth (\thebeamerpauses) \hypertarget<.(1)>{label4}{\beamerbutton{I'm on the fourth line}} \\
% fix here -----------------------------^^^
\pause
Fifth  (\thebeamerpauses) \\
\pause
Sixth  (\thebeamerpauses) \\
\end{frame}
\begin{frame}
\hyperlink{label4}{\beamerbutton{I jump to the fourth line of previous frame}}
\end{frame}

\begin{frame}[<+->]
\begin{itemize}
\item First  (\thebeamerpauses)
\item Second (\thebeamerpauses)
\item Third  (\thebeamerpauses)
\item Fourth (\thebeamerpauses) \hypertarget<.>{label42}{\beamerbutton{I'm on the fourth line}}
\item Fifth  (\thebeamerpauses)
\item Sixth  (\thebeamerpauses)
\end{itemize}
\end{frame}
\begin{frame}
\hyperlink{label42}{\beamerbutton{I jump to the fourth line of previous frame}}
\end{frame}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.