# Can I give a function to a label?

I try to create a dynamic way to give labels to my slides in Beamer.

\documentclass{beamer}

\newcommand{\partName}{blank}

%\includeonlyframes{firstChapter}
\begin{document}

\defPartName{firstChapter}
\begin{frame}[label=\partName]{A title}
The label of the current frame is \partName .
\end{frame}

\defPartName{secondChapter}
\begin{frame}[label=\partName]{A title}
The label of the current frame is \partName .
\end{frame}

\end{document}


The macro works, because the frames display the correct name of the current label. But they don't seem to "receive" the label, because when I use the \includeonlyframes{}, it doesn't work (which is precisely why I want to use it).

Any idea?

-
Just to make sure: doesn't \includeonlysection exist? (I dunno, I just try to find a natural way how to do what you do :-) ) – yo' Feb 6 '14 at 18:14
I precisely don't think so. But of course, I would be happy to use a more 'natural' way to do that :) – BonyHoax Feb 6 '14 at 18:38

It is possible if you add fragile to your frames

MWE:

\documentclass{beamer}

\newcommand{\partName}{blank}

\includeonlyframes{firstChapter}
\begin{document}

\defPartName{firstChapter}
\begin{frame}[fragile,label=\partName]{A title}
The label of the current frame is \partName .
\end{frame}

\defPartName{secondChapter}
\begin{frame}[fragile,label=\partName]{A title}
The label of the current frame is \partName .
\end{frame}

\end{document}


Output:

-
Ok thanks. But are there any consequences I should be aware of by using the 'fragile' option? – BonyHoax Feb 6 '14 at 18:39
I've edited my post to show an issue I have with this solution... – BonyHoax Feb 6 '14 at 19:06
@BonyHoax If you insert the code inside \chapterFrame directly in the document it works. It might be an expansion problem, but I can't figure out what it is. – karlkoeller Feb 6 '14 at 19:39