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?
[Tex/LaTex] How to modify outer theme infolines to include the title and section in the header beamer
beamerheader-footer
Related Solutions
You can redefine the section in head/foot
and section in head/foot shaded
templates to add \insertsectionheadnumber
. For the bonus, you need to redefine section in toc to add \inserttocsectionnumber
; an example illustrating these redefinitions:
\documentclass{beamer}
\usetheme{Singapore}
\setbeamertemplate{section in head/foot}{\hfill\insertsectionheadnumber.~\insertsectionhead}
\setbeamertemplate{section in head/foot shaded}{\color{structure!50}\hfill\insertsectionheadnumber.~\insertsectionhead}
\setbeamertemplate{section in toc}{\inserttocsectionnumber.~\inserttocsection}
\begin{document}
\section{Test Section One}
\begin{frame}
test
\end{frame}
\section{Test Section Two}
\begin{frame}
test
\end{frame}
\section{Test Section Three}
\begin{frame}
test
\end{frame}
\end{document}
An image of the resulting ToC showing the numbering both in the ToC entries and in the headline:
This is an alternative approach that tries to embed the actual mini frame navigation from the Frankfurt theme into the Cambridge theme. It requires major surgery and I'd suggest to make a custom theme with it.
First we need to set the miniframes color, I picked the darkred
color from the beaver
theme to match the rest of the theme.
\setbeamercolor{mini frame}{fg=darkred}
Now the tricky part: we are going to take the code from \insertsubsectionnavigationhorizontal
, remove its own \slideentry
macro and add the one taken from the beamerbasenavigation.sty
file. Since my etoolbox
fu is not good enough I'll just post the whole modified \slideentry
. For code readability etc. this should be placed in another file or done with etoolbox
.
\def\insertsubsectionnavigationhorizontal#1#2#3{%
\hbox to #1{{%
\usebeamerfont{subsection in head/foot}\usebeamercolor[fg]{subsection in head/foot}
\beamer@currentsubsection=0%
\def\sectionentry##1##2##3##4##5{}%
\def\slideentry##1##2##3##4##5##6{\ifnum##6=\c@part\ifnum##1=\c@section%
\ifnum##2>\beamer@currentsubsection%
\box\beamer@sectionbox\hskip1.875ex plus1fill%
\hbox to 0pt{%
\global\beamer@section@min@dim\beamer@tempdim
\beamer@link(##4){%
\usebeamerfont{mini frame}%
\ifnum\c@section=##1%
\ifnum\c@subsection=##2%
\usebeamercolor[fg]{mini frame}%
\ifnum\c@subsectionslide=##3%
\usebeamertemplate{mini frame}%\beamer@minislidehilight%
\else%
\usebeamertemplate{mini frame in current subsection}%\beamer@minisliderowhilight%
\fi%
\else%
\usebeamercolor{mini frame}%
%\color{fg!50!bg}%
\usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
\fi%
\else%
\usebeamercolor{mini frame}%
%\color{fg!50!bg}%
\usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
\fi%
}%
\hskip-10cm plus 1fil%
}%
\fi\fi\fi\ignorespaces
}%
#2\hskip.3cm\setbox\beamer@sectionbox=\hbox{}%
\hskip-1.875ex plus-1fill\dohead%
\box\beamer@sectionbox\hfil\hskip.3cm%
#3
}}
}
The last step is to re-set the headline template so that it calls our customized horizontal miniframes navigation:
\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}\bfseries\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}\setbeamercolor{section in head/foot}{fg=black,bg=white}
\vspace*{.01cm}\insertsubsectionnavigationhorizontal{0cm}{\hskip-.1cm}{}
\end{beamercolorbox}}%
\vskip0pt%
}
Result.
It works exactly as the Frankfurt miniframe nav. since it actually is the Frankfurt miniframe nav.
Full MWE.
\documentclass{beamer}
\usetheme{CambridgeUS}
\setbeamercolor{mini frame}{fg=darkred}
\makeatletter
\def\insertsubsectionnavigationhorizontal#1#2#3{%
\hbox to #1{{%
\usebeamerfont{subsection in head/foot}\usebeamercolor[fg]{subsection in head/foot}
\beamer@currentsubsection=0%
\def\sectionentry##1##2##3##4##5{}%
\def\slideentry##1##2##3##4##5##6{\ifnum##6=\c@part\ifnum##1=\c@section%
\ifnum##2>\beamer@currentsubsection%
\box\beamer@sectionbox\hskip1.875ex plus1fill%
\hbox to 0pt{%
\global\beamer@section@min@dim\beamer@tempdim
\beamer@link(##4){%
\usebeamerfont{mini frame}%
\ifnum\c@section=##1%
\ifnum\c@subsection=##2%
\usebeamercolor[fg]{mini frame}%
\ifnum\c@subsectionslide=##3%
\usebeamertemplate{mini frame}%\beamer@minislidehilight%
\else%
\usebeamertemplate{mini frame in current subsection}%\beamer@minisliderowhilight%
\fi%
\else%
\usebeamercolor{mini frame}%
%\color{fg!50!bg}%
\usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
\fi%
\else%
\usebeamercolor{mini frame}%
%\color{fg!50!bg}%
\usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
\fi%
}%
\hskip-10cm plus 1fil%
}%
\fi\fi\fi\ignorespaces
}%
#2\hskip.3cm\setbox\beamer@sectionbox=\hbox{}%
\hskip-1.875ex plus-1fill\dohead%
\box\beamer@sectionbox\hfil\hskip.3cm%
#3
}}
}
\makeatother
\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}\bfseries\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}\setbeamercolor{section in head/foot}{fg=black,bg=white}
\vspace*{.01cm}\insertsubsectionnavigationhorizontal{1cm}{\hskip-.1cm}{}
\end{beamercolorbox}}%
\vskip0pt%
}
\begin{document}
\section{Section 1}
\subsection{Subsection1}
\frame{S1s1f1}
\frame{S1s1f2}
\subsection{Subsection2}
\frame{S1s2}
\subsection{Subsection3}
\frame{S1s3}
\section{Section 2}
\subsection{Subsection1}
\frame{S2s1}
\subsection{Subsection2}
\frame{S2s2}
\subsection{Subsection3}
\frame{S2s3}
\subsection{Subsection4}
\frame{S2s4}
\end{document}
Best Answer
You can set the
headline
template:Notice that
infolines
by default inserts the title of the presentation in thefootline
template, so you'll also need to redefine this template to avoid duplicate information; here's one possible redefinition:And the result: