[Tex/LaTex] Custom navigation dots in beamer headline

beamerheader-footernavigation

I am working on my slides in beamer and I would like to include some dots in the header indicating the current section (left) and subsection (right). The names of the sections/subsections should not be included.

Here is a MWE:

\documentclass{beamer}

\makeatletter
\setbeamertemplate{headline}
{%
    \leavevmode%
    \hbox{%
        \begin{beamercolorbox}[wd=0.5\paperwidth,ht=2.25ex,dp=1ex,left]{section in head/foot}
            section dots
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=0.5\paperwidth,ht=2.25ex,dp=1ex,right]{section in head/foot}
            subsection dots (of current section)
        \end{beamercolorbox}}%
}
\makeatother

\begin{document}    
    \section{Section1}
    \begin{frame}
        \frametitle{Frame11}
    \end{frame}

    \subsection{Subsection1}
    \begin{frame}
        \frametitle{Frame12}
    \end{frame}

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


    \section{Section2}
    \begin{frame}
        \frametitle{Frame21}
    \end{frame}

    \subsection{Subsection1}
    \begin{frame}
        \frametitle{Frame22}
    \end{frame}

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

    \subsection{Subsection3}
    \begin{frame}
        \frametitle{Frame23}
    \end{frame}
\end{document}

For this specific number of frames, I want two dots in the top-left corner indicating the sections and two or three dots in the top-right corner indicating the subsections of section 1 and section 2, respectfully. Obviously, I want a general solution that is not specific to this example.

Is this done easily in my current setup or is something entirely different needed?

Best Answer

There are probably much better ways to do this, but instead of messing with beamer navigation I wanted to try something new and play with the xcntperchap package.

\documentclass{beamer}
\usepackage{tikz}

\usepackage{totcount}
\regtotcounter{section}

\usepackage{xcntperchap}
\RegisterCounters{section}{subsection}

\newcounter{totalsubsection}
\setcounter{totalsubsection}{0}
\usepackage{etoolbox}

\preto\frame{\ifnum\thesection>0\setcounter{totalsubsection}{\ObtainTrackedValueExp[\thesection]{section}{subsection}}\fi}

\setbeamertemplate{headline}{%
\hbox{%
\begin{beamercolorbox}[wd=.48\paperwidth,ht=2.25ex,dp=1ex]{section in head/foot}%
\hfill%
\ifnum\totvalue{section}>0%
\ifnum\thesection>0%
\foreach\x in {1,...,\totvalue{section}}{%
\ifnum\x=\thesection%
\usebeamertemplate{mini frame}~%
\else%
\usebeamertemplate{mini frame in other section}~%
\fi%
}%
\fi%
\fi%
\end{beamercolorbox}%
\qquad%
\begin{beamercolorbox}[wd=.48\paperwidth,ht=2.25ex,dp=1ex]{subsection in head/foot}%
\ifnum\thetotalsubsection>0%
\foreach\x in {1,...,\thetotalsubsection}{%
\ifnum\x=\thesubsection%
\usebeamertemplate{mini frame}~%
\else%
\usebeamertemplate{mini frame in other subsection}~%
\fi%
}%
\fi%
\end{beamercolorbox}%
}}

\title{title}
\author{author}

\begin{document}

    \begin{frame}
        \titlepage
    \end{frame}


\section{Section1}

\frame{}

\subsection{Subsection1}
\begin{frame}
\frametitle{Frame11}
\end{frame}

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

\section{Section2}
\begin{frame}
\frametitle{Frame2}
\end{frame}

\subsection{Subsection1}
\begin{frame}
\frametitle{Frame21}
\end{frame}

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

\subsection{Subsection3}
\begin{frame}
\frametitle{Frame23}
\end{frame}

\section{Section3}
\begin{frame}
\frametitle{Frame3}
\end{frame}

\end{document}

enter image description here

Related Question