1

I would like to use labels to assign overlay specifications. Below is the code I have so far. My main question is why does not the following terminate to compile.

\documentclass[11pt]{beamer}
\usepackage{pgfkeys}
\pgfkeys{/.unknown/.code=%
        {\PackageError{some name}{Label \pgfkeyscurrentname{} not defined}{}}%
}
\begin{document}
    \begin{frame}{Title}        
        \pgfkeys{/bar 1/.append={2}}
        \pgfkeys{/foo 2/.append={1}}
        \begin{itemize}
            \item<\pgfkeys{/bar 1}> Some bar
            \item<\pgfkeys{/foo 2}> and foo
        \end{itemize}
    \end{frame}
\end{document}

My solution so far:

The following code fixes the issue above. However, when I write one of the labels in the overlay specification wrong pdflatex does not terminate, as the key is unknown. That means, the .unknown handler is ignored, which is why I am not satisfied with my solution..

\documentclass[11pt]{beamer}
\usepackage{pgfkeys}
\pgfkeys{/.unknown/.code=%
    {\PackageError{some name}{Label \pgfkeyscurrentname{} not defined}{}}%
}
\begin{document}    
    \begin{frame}{Title}        
        \pgfkeys{/bar 1/.append={2}}
        \pgfkeys{/foo 2/.append={1}}
        \begin{itemize}
            \item<\pgfkeysvalueof{/bar 1}> Some bar
            \item<\pgfkeysvalueof{/foo 2}> and foo
        \end{itemize}
    \end{frame}
\end{document}

Related Questions:

Here it was suggested to just redefine \item. However, I am not sure how to redefine the overlay macros in a good and general way. With my current approach I can use the label approach with all overlay aware commands.

Here I asked about this the first time. I got it working without pgfkeys, storing the values in macros. But then I can only use letters in labels, which is inconvenient.

Here it was suggest to protect the pgfkeys command with \protect but that did not work. Thought it is related as the resulting problem is the same.

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.