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 have a beamer main document which is called by various wrappers and I want to make all \mode-switching dependent from commands defined in the preamble of this wrappers. For normal modes like \mode<presentation> this works fine, but the only way I found to include \mode* in this system was to hack an internal command.

Has someone a better idea to achieve the same goal? And do someone some danger in my redefinition (apart from the general danger to redefine internal commands)?

\documentclass[]{beamer}
\newcommand\secondmode{presentation}
\newcommand\mainmode{*}
\makeatletter
\def\beamer@@@mode<#1>{\if#1*
                          \expandafter\@firstoftwo
                        \else
                          \expandafter\@secondoftwo
                        \fi
                        {\beamer@modeoutsideframe}
                        {\beamer@closer\@ifnextchar\bgroup{\beamer@modeinline<#1>}{\beamer@switchmode<#1>}}}
\makeatother
\begin{document}
\mode
<\mainmode>
some text outside a frame in main mode
\begin{frame}
test in frame in main mode
\end{frame}


\mode
<\secondmode>

some text outside a frame in second mode

\begin{frame}
second mode in a frame
\end{frame}

\mode
<\mainmode>

some text outside a frame


\mode
<all>
\end{document}
share|improve this question

1 Answer 1

I don't know beamer well enough to be able to say whether a completely different technique should be used but at least I think you want to change

\if#1*


\if*#1%

as otherwise if the first two letters of the mode name are the same it will expand to true and typeset the remaining letters followed by a *.

In the MWE it is testing the p and r of presentation so it happens to take the right branch, but compare with:

\newcommand\secondmode{ppesentation}
share|improve this answer
    
Good point. It doesn't matter currently but is naturally cleaner. –  Ulrike Fischer Feb 23 '13 at 9:47

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.