[Tex/LaTex] Editing partly Beamer header (with existing theme content)

beamerheader-footerthemes

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 :
enter image description here


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 :

enter image description here
(source : http://www.hartwork.org/beamer-theme-matrix/)

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.

enter image description here

(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.


Best Answer

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}

enter image description here