7

I am trying to reference my beamer overlays by an identifier, much like in this question: reference overlay numbers with names.

Since I am using \visible<+->{} (where the beamerpauses counter is incremented after the execution of the command), I wanted to use the extensions mentioned in this comment and this comment in order to be able to define offsets.

When using the alternative \savepause definition, I get the error:

"You can't use `\unhbox' after \advance. \end{frame}"

When using the alternative \usepauseoffset, I get an error ...

"undefined control sequence".

Actually, it's a whole bunch of errors in both cases. I'm not yet experienced enough with LaTeX to program macros and understand such error messages.

Here is an MWE:

\documentclass{beamer}

% Save overlays by name
\makeatletter
\DeclareRobustCommand*{\savepause}[1]{\only<1>{\immediate\write\@auxout{\string\pauseentry{\the\c@framenumber}{#1}{\the\c@beamerpauses}}}}
%\DeclareRobustCommand*{\savepause}[2][0]{\only<1>{\advance\c‌​@beamerpauses by#1\relax\immediate\write\@auxout{\string\pauseentry{\the\c‌​@framenumber}{#2}{\t‌​he\c@beamerpauses}}\‌​advance\c@beamerpaus‌​es by-#1\relax}}
\newcommand*{\usepause}[1]{\@ifundefined{pauses@\the\c@framenumber @#1}{1}    {\@nameuse{pauses@\the\c@framenumber @#1}}}
\def\usepauseoffset[#1]#2{\number\numexpr\usepause{#2}+#1\re‌​lax}
\newcommand*{\pauseentry}[3]{\global\@namedef{pauses@#1@#2}{#3}}
\makeatother

\begin{document}

\begin{frame}
    \visible<+->{Overlay 1 \savepause{first} (Counter: \usepause{first})}

    \visible<+->{Overlay 2 \savepause{second} (Counter: \usepause{second})}

    \visible<\usepause{first}->{Should be shown together with "Overlay 1".}

    %\visible<\usepauseoffset[1]{second}->{Should be shown together with "Overlay 2".} % Does not compile.
\end{frame}

\end{document}

I'm sorry that I did not comment under the original question, but I do not yet have the privileges to comment.

In case anything is missing in my explanation, please let me know. I just joined Stackexchange.

Thanks in advance!

Your Answer

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

Browse other questions tagged or ask your own question.