# Editing partly Beamer header (with existing theme content)

## MWE :

Considering the following minimal working example :

\documentclass{beamer}
\usetheme{CambridgeUS}

\begin{document}

\section{Section1}
\subsection{Subsection1}
\begin{frame}
\end{frame}

\subsection{Subsection2}
\begin{frame}
\end{frame}

\end{document}


Which renders as follow :

## Question :

I would like to remove the automatic content placed on header right (the subsection content) and place there instead some dots counting how many slides remain for the current section. By dots I mean :

• the number of dots tells how much slides we have for the section (not considering the pauses!) ;
• if they are white full, we read the slides
• if it is empty :
1. empty in white, we are reading it ;
2. if they are empty grey, we didn't read them yet.

## It seems that it exists already :

I have seen these kind of dots on some other themes like Frankfurt :

I guess it can be exploited, but I am not expert enough in latex to do it.

## Example of the expected display :

On this example, we have 6 pages for this Section1, and we are currently on the second page for this section.

(Of course the background doesn't have to be black, it's just a bad edit made by hand)

## Summary :

How can I place these dots instead of the subsection on this CambridgeUS theme ? Is this possible to integrate the Frankfurt code regarding these dots inside CambridgeUS theme ?

Thanks in advance for your help.

• does tex.stackexchange.com/a/162786/36296 help? – user36296 Sep 3 '14 at 14:51
• Thank you for your answer. I have seen this post, however, I do not understand how I can apply it to perform what I am looking for. Could you please explain me how I can insert these part of code into CambridgeUS theme in order to get the display given above ? – enigmator Sep 3 '14 at 14:55

## 2 Answers

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}


• thank you for your answer. Yes that's exactly what I am looking except that it displays the full number of slides (and not the ones of the current section), as you mentioned in your "Drawbacks" section. Whenever you find a solution for this, please let us know =) – enigmator Sep 4 '14 at 13:16
• @enigmator I will :) That is actually a "feature" of the Frankfurt theme, so when you import the slideentry macro from that theme you get that too... – Nico Boni Sep 4 '14 at 13:20
• Did you figured out a solution about that ? – enigmator Sep 5 '14 at 13:13
• @enigmator see the edited answer, it should work fine now. – Nico Boni Sep 5 '14 at 20:13

\documentclass[compress]{beamer}
\usetheme{CambridgeUS}
\useoutertheme{miniframes}
\useoutertheme{split}
%\usecolortheme{whale}

\makeatletter

\newcount\beamer@xoff
\newcount\beamer@prev@section
\newcount\beamer@prev@miniframes
\beamer@xoff=0
\beamer@prev@section=0
\beamer@prev@miniframes=0

\def\insertsubsectionnavigationhorizontalminiframes#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##1>\beamer@prev@section%
\beamer@xoff=##3\relax%
\beamer@prev@miniframes=0\relax%
\fi
\ifnum##6=\c@part\ifnum##1=\c@section%
\ifnum##2>\beamer@currentsubsection%
\beamer@xoff=0\relax%
\beamer@currentsubsection=##2%
\box\beamer@sectionbox\hskip1.875ex plus1fill%
\ifnum\beamer@prev@miniframes>0\relax%
\beamer@tempdim=\beamer@boxsize%
\multiply\beamer@tempdim by \beamer@prev@miniframes%
\advance\beamer@tempdim by -\beamer@boxsize%
\advance\beamer@tempdim by 2pt%
\ifnum##2>1%
\advance\beamer@tempdim by 1.875ex%
\else
\advance\beamer@tempdim by -\beamer@boxsize%
\fi
\else
\beamer@tempdim=0pt%
\fi
\setbox\beamer@sectionbox=
\hbox{\def\insertsubsectionhead{\kern\beamer@tempdim##5}%
\def\insertsectionheadnumber{##1}%
\def\insertsubsectionheadnumber{##2}%
\def\insertpartheadnumber{##6}%
\ifnum\c@subsection=##2%
\beamer@link(##4){{\usebeamertemplate{subsection in head/foot}}}\else%
\beamer@link(##4){{\usebeamertemplate{subsection in head/foot shaded}}}\fi}%
\ht\beamer@sectionbox=1.875ex%
\dp\beamer@sectionbox=0.75ex%
\else%
\beamer@prev@miniframes=##3%
\fi%
\setbox0=\hbox{\insertsectionhead\unskip}\ifdim\wd0>0pt\ifnum##3>0%
\beamer@xpos=##3\relax%
\advance\beamer@xpos by -\beamer@xoff%
\hbox to 0pt{%
\beamer@tempdim=0.5pt%
\raise\beamer@tempdim\hbox{%
\ifnum##2>0%
\beamer@tempdim=\beamer@boxsize%
\multiply\beamer@tempdim by\beamer@xpos%
\advance\beamer@tempdim by -\beamer@boxsize%
\advance\beamer@tempdim by 2pt%
\advance\beamer@tempdim by \wd\beamer@sectionbox%
\else%
\beamer@tempdim=\beamer@boxsize%
\multiply\beamer@tempdim by\beamer@xpos%
\advance\beamer@tempdim by 1.875ex%
\fi%
\kern\beamer@tempdim\hbox{\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}%
\else%
\usebeamertemplate{mini frame in current subsection}%
\fi%
\else%
\usebeamercolor{mini frame}%
\usebeamertemplate{mini frame in other subsection}%
\fi%
\else%
\usebeamercolor{mini frame}%
\usebeamertemplate{mini frame in other subsection}%
\fi%
}}}\hskip-10cm plus 1fil%
}\fi\fi%
\else%
\fakeslideentry{##1}{##2}{##3}{##4}{##5}{##6}%
\fi\fi%
\beamer@prev@section=##1%
\ignorespaces}%
#2\hskip.3cm\setbox\beamer@sectionbox=\hbox{}%
\hskip-1.875ex plus-1fill\dohead%
\box\beamer@sectionbox\hfil\hskip.3cm%
#3}}}

\setbeamercolor{mini frame}{parent=subsection in head/foot}
\setbeamercolor{section in head/foot}{fg=white}

\ifbeamer@compress

\defbeamertemplate*{headline}{split theme miniframes}
{%
\leavevmode%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex]{palette tertiary}%
\usebeamercolor{palette tertiary} \insertsectionnavigationhorizontal{.5\paperwidth}{\hskip0pt plus1filll}{}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex]{subsection in head/foot}%
\insertsubsectionnavigationhorizontalminiframes{.5\paperwidth}{}{\hskip0pt plus1filll}%
\end{beamercolorbox}%
}

\else

\defbeamertemplatealias{headline}{split theme miniframes}{split theme}
\setbeamertemplate{headline}[split theme miniframes]

\fi

\makeatother

% This is to enable the feature
\setbeamertemplate{headline}[split theme miniframes]
\setbeamertemplate{footline}[infolines theme]

\begin{document}

\section{Section1}

\begin{frame}
\end{frame}

\begin{frame}
\end{frame}

\end{document}

• Thank you, It's quite that apart from 2 details : if you try with 2 sections, you will notice that they are all written in the left header (I simply want the current section). Also regarding the dots, it doesn't seem to be the same rles as on Frankfurt theme, which is 1) full+color for already read slides, 2) empty+color for current slide, 3) empty for all last pages not read. On the code you propose me, we only have the full dot for the current slide. You see what I mean? – enigmator Sep 3 '14 at 18:23