Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

\documentclass{beamer}

\newcommand{\partName}{blank}
\newcommand {\defPartName}[1]{\renewcommand{\partName}{#1}}

%\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?

share|improve this question
    
Just to make sure: doesn't \includeonlysection exist? (I dunno, I just try to find a natural way how to do what you do :-) ) –  tohecz Feb 6 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 at 18:38
add comment

1 Answer

up vote 7 down vote accepted

It is possible if you add fragile to your frames

MWE:

\documentclass{beamer}

\newcommand{\partName}{blank}
\newcommand {\defPartName}[1]{\renewcommand{\partName}{#1}}

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

enter image description here

share|improve this answer
    
Ok thanks. But are there any consequences I should be aware of by using the 'fragile' option? –  BonyHoax Feb 6 at 18:39
    
I've edited my post to show an issue I have with this solution... –  BonyHoax Feb 6 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 at 19:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.