11

I am working on a beamer template which tries to mimick an existing .ppt-template from my institute. My problem now is, that the beamer template should be able to have frames with different styles for the headline within a single presentation. (do not ask why this would be necessary, I do not know)

After having a look into beamerbaseframe.sty and playing a bit with frame options, I came up with the following code

\documentclass{beamer}

\usetheme{mytheme}

\begin{document}

    \begin{frame}
        left
    \end{frame} 

    \begin{frame}[rightslide]
        right
    \end{frame} 

    \begin{frame}
        should be left again :(
    \end{frame}     

\end{document}

using beamerthememytheme.sty

\setbeamertemplate{headline}{%
    \rule{.5\paperwidth}{14mm}
}

\define@key{beamerframe}{rightslide}[true]{%
    \setbeamertemplate{headline}{\hfill\rule{.5\paperwidth}{14mm}}%
}

So the question is now: how can I revert to the default headline after the slide with the option rightslide?

enter image description here

2 Answers 2

16
+200

You can define two different templates and reset the headline to the default style before a new frame starts.

\documentclass{beamer}
\usepackage{etoolbox}

\defbeamertemplate{headline}{mydefault}{%
  \rule{.5\paperwidth}{14mm}%
}
\defbeamertemplate{headline}{rightslide}{%
  \emph{\hfill\rule{.5\paperwidth}{14mm}}%
}

\BeforeBeginEnvironment{frame}{%
  \setbeamertemplate{headline}[mydefault]%
}

\makeatletter
\define@key{beamerframe}{rightslide}[true]{%
  \setbeamertemplate{headline}[rightslide]%
}
\makeatother

\begin{document}

\begin{frame}
  left
\end{frame} 

\begin{frame}[rightslide]
  right
\end{frame}

\begin{frame}
  is left again
\end{frame}

\end{document}

enter image description here

1
0

Using a similar approach as the moloch beamer theme for its standout frame, one could use a group to restrict the changes to just this one frame:

\documentclass{beamer}

\makeatletter
\setbeamertemplate{headline}{%
    \rule{.5\paperwidth}{14mm}
}

\providebool{rightslide}
\define@key{beamerframe}{rightslide}[true]{%
    \booltrue{rightslide}
    \begingroup
    \setbeamertemplate{headline}{\hfill\rule{.5\paperwidth}{14mm}}%
}
\pretocmd{\beamer@reseteecodes}{%
  \ifbool{rightslide}{
    \endgroup
    \boolfalse{rightslide}
  }{}
}{}{}
\makeatother

\begin{document}

    \begin{frame}
        left
    \end{frame} 

    \begin{frame}[rightslide]
        right
    \end{frame} 

    \begin{frame}
        is left again :)
    \end{frame}     

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .