# Beamer: Reference Overlay Numbers with Names

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
\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.