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 Answers2

16

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

esdd
  • 85,675
  • I made use of your code in my answer here (last one added), so thanks! https://tex.stackexchange.com/questions/8043 – PatrickT Oct 10 '17 at 09:04
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