[Tex/LaTex] How to modify outer theme infolines to include the title and section in the header beamer

beamerheader-footer

I am using the CambridgeUS beamer theme for a presentation and would like to modify the header to include the title of the presentation on the left and the section on the right, as I do not have many subsections. A modification to the infolines command seemed like the way to go, but this is apparently not possible without modifying the sty file itself. Does anyone have a fix?

Best Answer

You can set the headline template:

\documentclass{beamer}
\usetheme{CambridgeUS}

\setbeamertemplate{headline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,right,rightskip=1em]{section in head/foot}%
    \usebeamerfont{subsection in head/foot}\hspace*{2ex}\insertshorttitle
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,left,leftskip=1em]{subsection in head/foot}%
    \usebeamerfont{section in head/foot}\insertsectionhead\hspace*{2ex}
  \end{beamercolorbox}}%
  \vskip0pt%
}

\title{The Title}
\author{The Author}

\begin{document}

\section{Test Section One}
\begin{frame}
test
\end{frame}

\section{Test Section Two}
\begin{frame}
test
\end{frame}

\end{document}

Notice that infolines by default inserts the title of the presentation in the footline template, so you'll also need to redefine this template to avoid duplicate information; here's one possible redefinition:

\documentclass{beamer}
\usetheme{CambridgeUS}

\setbeamertemplate{headline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,right,rightskip=1em]{section in head/foot}%
    \usebeamerfont{subsection in head/foot}\hspace*{2ex}\insertshorttitle
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,left,leftskip=1em]{subsection in head/foot}%
    \usebeamerfont{section in head/foot}\insertsectionhead\hspace*{2ex}
  \end{beamercolorbox}}%
  \vskip0pt%
}

\makeatletter
\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor~~\beamer@ifempty{\insertshortinstitute}{}{(\insertshortinstitute)}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
    \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
    \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
  \end{beamercolorbox}}%
  \vskip0pt%
}
\makeatother

\title{The Title}
\author{The Author}

\begin{document}

\section{Test Section One}
\begin{frame}
test
\end{frame}

\section{Test Section Two}
\begin{frame}
test
\end{frame}

\end{document}

And the result:

enter image description here

enter image description here