[Tex/LaTex] Beamer infolines outer theme with miniframe bullets only for the current section

beamermini-framesnavigationsectioning

I am wondering whether we can use the subsection part of the beamer infolines outer theme headline (the right half) to show the miniframe bullets of the current section. Assuming the section has three frames, the headline would look like this

First frame of the section:

       Section Title @oo
       Frame title 

Next frame of the section:

       Section Title o@o
       Frame title 

and so on.

I guess this can be done by hacking around \dohead, but I couldn't figure out how to tweak things. Any help will be greatly appreciated.

Best Answer

This is quite a hackish solution: It starts with the miniframes outer theme and patches the internal beamer commands in order to remove the other sections from the headline:

\documentclass{beamer}

% "Beamer infolines outer theme with miniframe bullets only for the current section"
% (http://tex.stackexchange.com/a/45152/3323)
\useoutertheme[subsection=false]{miniframes}
\setbeamertemplate{mini frame in other section}{}
\usepackage{etoolbox}
\makeatletter
\let\beamer@section@set@min@width=\relax
\patchcmd{\insertnavigation}{\hskip-1.875ex plus-1fill}{}{}{}
\patchcmd{\sectionentry}{\hskip1.875ex plus 1fill}{}{}{}
\patchcmd{\sectionentry}{\hyperlink{Navigation#3}{{\usebeamertemplate{section in head/foot shaded}}}}{}{}{}
\patchcmd{\slideentry}{\usebeamertemplate{mini frame in other subsection}}{\usebeamertemplate{mini frame in other subsection of current section}}{}{}
\patchcmd{\slideentry}{\usebeamertemplate{mini frame in other subsection}}{\usebeamertemplate{mini frame in other section}}{}{}
\patchcmd{\slideentry}{\usebeamertemplate{mini frame in other subsection of current section}}{\usebeamertemplate{mini frame in other subsection}}{}{}
\makeatother

\begin{document}
\section{Section 1}
\subsection{Subsection 1}
\frame{\frametitle{Frame 1}}
\frame{\frametitle{Frame 2}}
\frame{\frametitle{Frame 3}}
\subsection{Subsection 2}
\frame{\frametitle{Frame 1}}
\frame{\frametitle{Frame 2}}
\frame{\frametitle{Frame 3}}
\frame{\frametitle{Frame 4}}
\section{Section 2}
\subsection{Subsection 1}
\frame{\frametitle{Frame 1}}
\frame{\frametitle{Frame 2}}
\frame{\frametitle{Frame 3}}
\frame{\frametitle{Frame 4}}
\subsection{Subsection 2}
\frame{\frametitle{Frame 1}}
\frame{\frametitle{Frame 2}}
\frame{\frametitle{Frame 3}}
\frame{\frametitle{Frame 4}}
\frame{\frametitle{Frame 5}}
\end{document}

Example headline:

example headline: section 2, subsection 1, frame 3

(If you want to have all mini frames in one line instead of using a single line per subsection, you can use \documentclass[compress]{beamer} as usual.)


Explanation of the code:

We use the outer theme miniframes and remove all the mini frames that do not belong to the current section:

\useoutertheme[subsection=false]{miniframes}
\setbeamertemplate{mini frame in other section}{}

Now, etoolbox is used to remove some code from the beamer macros responsible for generating the navigation bar:

  • Remove the space between the sections:

    \let\beamer@section@set@min@width=\relax
    \patchcmd{\insertnavigation}{\hskip-1.875ex plus-1fill}{}{}{}
    \patchcmd{\sectionentry}{\hskip1.875ex plus 1fill}{}{}{}
    
  • Do not display sections other than the current section at all:

    \patchcmd{\sectionentry}{\hyperlink{Navigation#3}{{\usebeamertemplate{section in head/foot shaded}}}}{}{}{}
    
  • Fix an inconsistency in the current beamer version: currently, the template mini frame in other subsection is used for both mini frames in the current section and other sections, where the latter case should use mini frame in other section:

    \patchcmd{\slideentry}{\usebeamertemplate{mini frame in other subsection}}{\usebeamertemplate{mini frame in other subsection of current section}}{}{}
    \patchcmd{\slideentry}{\usebeamertemplate{mini frame in other subsection}}{\usebeamertemplate{mini frame in other section}}{}{}
    \patchcmd{\slideentry}{\usebeamertemplate{mini frame in other subsection of current section}}{\usebeamertemplate{mini frame in other subsection}}{}{}