# Relative Overlays with pgfkeys

I would like to create relative overlays in beamer with a different notation than the existing one. The following code gives satisfying results.

\documentclass{beamer}
\usepackage{pgfkeys}
\newcommand\getspec[1]{\pgfkeysvalueof{/#1/spec}}
\begin{document}
\begin{frame}{}
\pgfkeyssetvalue{/1st item/spec}{1-2}
\pgfkeyssetvalue{/2nd item/spec}{2}
\begin{itemize}
\item<\getspec{1st item}> Content
\item<\getspec{2nd item}> More content
\end{itemize}
\end{frame}
\end{document}


Because keys in pgfkeys are local to the current group the following code throws an error Missing number, treated as zero., because after the first frame-environment is left, the value of the key 1st item is set to something like an empty string.

\documentclass{beamer}
\usepackage{pgfkeys}
\newcommand\getspec[1]{\pgfkeysvalueof{/#1/spec}}
\begin{document}
\begin{frame}{}
\pgfkeyssetvalue{/1st item/spec}{1-2}
\pgfkeyssetvalue{/2nd item/spec}{2}
\begin{itemize}
\item<\getspec{1st item}> Content
\item<\getspec{2nd item}> More content
\end{itemize}
\end{frame}

\begin{frame}{}
\begin{itemize}
\item<\getspec{1st item}> Content
\end{itemize}
\end{frame}
\end{document}


I would like to adapt the code of getspec to give a more useful error message. Something like this label has not been defined for the current frame would be nice.

This is related to Relative Order of Overlays in Beamer and to external link.

The following kind of works:

\newcommand\getspec[1]{
\pgfkeysifdefined{/#1/spec}{
\pgfkeysvalueof{/#1/spec} % The key is defined
}{ 0| stop:0| % Dirty hack
\errmessage{Label "#1" has not been defined for the current frame}
}
}


Which produces the following error:

! Label "1st item" has not been defined for the current frame.
\beamer@@@temp ...n defined for the current frame}
| stop:0|
l.24 \end{frame}


The | stop:0| hack escapes from the Beamer parsing which expects numbers, but note that this might not work with every Beamer version.

• I thought I tried \pgfkeysifdefined.. Anyway, thanks! – Heinrich Ody Feb 13 '17 at 8:53