2

I am attempting to modify the section in header of my beamer. I use outer theme infolines. The command \setbeamertemplate has no effect in my case. Below is my MWE:

\documentclass{beamer}
\useoutertheme{infolines}
\setbeamertemplate{section in head/foot}{\hfill\thesection.\insertsectionhead}
\setbeamertemplate{section in head/foot shaded}{\hfill\thesection.\insertsectionhead}
\begin{document}
    \section{title}
    \begin{frame}
        content...
    \end{frame}
\end{document}

Why I cannot redefine the section in header or footer using command \setbeamertemplate?

  • infolines theme defines a header and a footer that doesn't use section in head/foot. – Ignasi May 10 '16 at 18:59
  • @Ignasi so what is the beamer element used? – Say OL May 11 '16 at 1:05
  • It's a beamercolorbox which calls \insertsectionhead. You can look for it. Search beamerouterthemeinfolines.sty file in your system or read it from CTAN – Ignasi May 11 '16 at 6:05
  • @Ignasi so this means that we are not able to simply use \setbeamertemplate to redefine the section in header in infolines outer theme! – Say OL May 11 '16 at 6:10
3

If you look at file beamerouterthemeinfolines.sty where infolines outer theme is defined will see that infolines headline is defined with a beamercolorbox and not with a section in head/foot template. So if you want to change this theme it's better to take the original definition and change it according your taste. This is what I've done in following code. The original \defbeamertemplate*{headline} has been copied and converted to \setbeamertemplate, inserted between \makeatother+\makeatletter and changed to show \thesection.\insertsectionhead.

\documentclass{beamer}

\makeatletter
\setbeamertemplate{headline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,right]{section in head/foot}%
    \usebeamerfont{section in head/foot}\thesection.\insertsectionhead\hspace*{2ex}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,left]{subsection in head/foot}%
    \usebeamerfont{subsection in head/foot}\hspace*{2ex}\insertsubsectionhead
  \end{beamercolorbox}}%
  \vskip0pt%
}
\makeatother

\begin{document}
    \section{title}
    \subsection{subsection}
    \begin{frame}
        content...
    \end{frame}
    \section{new title}
    \subsection{another subsection}
    \begin{frame}
        content...
    \end{frame}
\end{document}

This is the result:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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