# Custom frame: automatic frametitle and framesubtitle with miniframes-like bullets?

I'm trying to define my own minimal frametitle style. I'm close to want I want, but I struggle to get automatic miniframes-like bullets.

Is there any simple way to use the built-in bullet navigation in beamer miniframes to obtain what I want?

(Also feel free to criticise the way I did things, as it is probably not it should be done!)

MWE:

\documentclass{beamer}
\usepackage{textcomp} % for \textopenbullet

\setbeamercolor{frametitle}{bg=black!20}

\setbeamertemplate{frametitle}
{
\nointerlineskip
\begin{beamercolorbox}[sep=0.0cm,ht=10mm,wd=\paperwidth]{frametitle}
\vbox{}\vskip-0ex%
\strut%
\hspace*{4mm}\insertframetitle%
\ifx\insertframesubtitle
\newline\hspace*{4mm}\small\strut\phantom{Pq}%
\else
\newline\hspace*{4mm}\small\strut\insertframesubtitle%
\fi
\end{beamercolorbox}
}

\makeatletter
\CheckCommand*\beamer@checkframetitle{\@ifnextchar\bgroup\beamer@inlineframetitle{}}
\renewcommand*\beamer@checkframetitle{\global\let\beamer@frametitle\relax\@ifnextchar\bgroup\beamer@inlineframetitle{}}
\makeatother

\begin{document}

\part{Part1}
\section{Sec1}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textopenbullet\textopenbullet\textopenbullet\textopenbullet)
\end{frame}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textopenbullet\textopenbullet\textopenbullet)
\end{frame}

\subsection{Subsec1.1}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textbullet\textopenbullet\textopenbullet)\\
Subsec1.1 (\textbullet\textopenbullet)
\end{frame}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textbullet\textbullet\textopenbullet)\\
Subsec1.1 (\textbullet\textbullet)
\end{frame}

\subsection{Subsec1.2}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textbullet\textbullet\textbullet)\\
Subsec1.1\\[5mm]
Note that when there is only one frame in section or subsection, no bullets should be shown.
\end{frame}

\section{Sec2}
\subsection{Subsec2.1}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec2 (\textbullet\textopenbullet\textopenbullet)\\
Subsec2.1\\[5mm]
Note that when there is only one frame in section or subsection, no bullets should be shown.
\end{frame}

\subsection{Subsec2.2}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec2 (\textbullet\textbullet\textopenbullet)\\
Subsec2.1 (\textbullet\textopenbullet)\\[1cm]
\end{frame}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec2 (\textbullet\textbullet\textbullet)\\
Subsec2.1 (\textbullet\textbullet)\\[1cm]
\end{frame}

\end{document}


# =================

EDIT: getting real close to want I want, thanks to samcarter comment! But there are still a few things to iron out (see the new MWE).

New MWE:

\documentclass{beamer}
\usepackage{textcomp} % for \textopenbullet

\setbeamercolor{frametitle}{bg=black!20}

\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{etoolbox}

\makeatletter
\newcount\beamer@subsectionstartframe
\beamer@subsectionstartframe=1
\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
\def\beamer@startframeofsubsection{1}
\def\beamer@endframeofsubsection{1}
\def\beamer@subsectionframes#1#2{%
\else%
\else%
\gdef\beamer@startframeofsubsection{#1}%
\gdef\beamer@endframeofsubsection{#2}%
\fi%
\fi%
}
\newcommand\insertsubsectionstartframe{\beamer@startframeofsubsection}
\newcommand\insertsubsectionendframe{\beamer@endframeofsubsection}

\newcount\beamer@sectionstartframe
\beamer@sectionstartframe=1
\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
\def\beamer@startframeofsection{1}
\def\beamer@endframeofsection{1}
\def\beamer@sectionframes#1#2{%
\else%
\else%
\gdef\beamer@startframeofsection{#1}%
\gdef\beamer@endframeofsection{#2}%
\fi%
\fi%
}
\newcommand\insertsectionstartframe{\beamer@startframeofsection}
\newcommand\insertsectionendframe{\beamer@endframeofsection}
\makeatother

\setbeamertemplate{frametitle}
{
\nointerlineskip
\begin{beamercolorbox}[sep=0.0cm,ht=10mm,wd=\paperwidth]{frametitle}
\vbox{}\vskip-0ex%
\strut%
\hspace*{4mm}\insertframetitle\ (%
\ifnum\value{section}>0%
\textbullet%
\else%
\textopenbullet%
\fi%
}%
\fi%
)%
\ifx\insertframesubtitle
\newline\hspace*{4mm}\small\strut\phantom{Pq}%
\else
\newline\hspace*{4mm}\small\strut\insertframesubtitle\ (%
\ifnum\value{section}>0%
\textbullet%
\else%
\textopenbullet%
\fi%
}%
\fi%
\fi%
)%
\end{beamercolorbox}
}

\makeatletter
\CheckCommand*\beamer@checkframetitle{\@ifnextchar\bgroup\beamer@inlineframetitle{}}
\renewcommand*\beamer@checkframetitle{\global\let\beamer@frametitle\relax\@ifnextchar\bgroup\beamer@inlineframetitle{}}
\makeatother

\begin{document}

\part{Part1}

\section{Sec1}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textopenbullet\textopenbullet\textopenbullet\textopenbullet)\\[5mm]

\color{red}Note that when there is no subsection, no bullets should be shown.
\end{frame}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textopenbullet\textopenbullet\textopenbullet)\\[5mm]

\color{red}Note that when there is no subsection, no bullets should be shown.
\end{frame}

\subsection{Subsec1.1}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textbullet\textopenbullet\textopenbullet)\\
Subsec1.1 (\textbullet\textopenbullet)
\end{frame}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textbullet\textbullet\textopenbullet)\\
Subsec1.1 (\textbullet\textbullet)
\end{frame}

\subsection{Subsec1.2}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textbullet\textbullet\textbullet)\\
Subsec1.2\\[5mm]
\color{red}Note that when there is only one frame in section or subsection, no bullets should be shown.
\end{frame}

\section{Sec2}

\subsection{Subsec2.1}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec2 (\textbullet\textopenbullet\textopenbullet)\\
Subsec2.1\\[5mm]
\color{red}Note that when there is only one frame in section or subsection, no bullets should be shown.
\end{frame}

\subsection{Subsec2.2}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec2 (\textbullet\textbullet\textopenbullet)\\
Subsec2.2 (\textbullet\textopenbullet)\\[5mm]

\color{red}I don't know why there is 3 bullets in the subsection here.
\end{frame}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec2 (\textbullet\textbullet\textbullet)\\
Subsec2.2 (\textbullet\textbullet)\\[5mm]

\color{red}I don't know why there is 3 bullets in the subsection here.
\end{frame}

\section{Sec3}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec3\\[5mm]

\color{red}I don't know why there is 3 bullets in the subsection here.
\end{frame}

\end{document}


• when there is no subsection, no bullets should be shown: You can test if you are outside of a subsubsection with \ifnum\thesubsection=0

• when there is only one frame in section or subsection, no bullets should be shown: If there is only one frame in the (sub)section, then the start end frame is the same. This can be tested by \ifnum\insertsubsectionstartframe=\insertsubsectionendframe and \ifnum\insertsectionstartframe=\insertsectionendframe

• why there are 3 bullets in the subsection: I think this boils down to the fact that the section end is not recognised as as subsection end as well. As a workaround this situation can be caught by testing \ifnum\insertsubsectionendframe<\insertsectionendframe

\documentclass{beamer}
\usepackage{textcomp} % for \textopenbullet

\setbeamercolor{frametitle}{bg=black!20}

\usepackage{tikz}
\usetikzlibrary{calc}
%\usepackage{etoolbox}

\makeatletter
\newcount\beamer@subsectionstartframe
\beamer@subsectionstartframe=1

\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
\def\beamer@startframeofsubsection{1}
\def\beamer@endframeofsubsection{1}
\def\beamer@subsectionframes#1#2{%
\else%
\else%
\gdef\beamer@startframeofsubsection{#1}%
\gdef\beamer@endframeofsubsection{#2}%
\fi%
\fi%
}
\newcommand\insertsubsectionstartframe{\beamer@startframeofsubsection}
\newcommand\insertsubsectionendframe{\beamer@endframeofsubsection}

\newcount\beamer@sectionstartframe
\beamer@sectionstartframe=1
\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
\def\beamer@startframeofsection{1}
\def\beamer@endframeofsection{1}
\def\beamer@sectionframes#1#2{%
\else%
\else%
\gdef\beamer@startframeofsection{#1}%
\gdef\beamer@endframeofsection{#2}%
\fi%
\fi%
}
\newcommand\insertsectionstartframe{\beamer@startframeofsection}
\newcommand\insertsectionendframe{\beamer@endframeofsection}
\makeatother

\newcounter{stopframe}

\setbeamertemplate{frametitle}
{
\nointerlineskip
\begin{beamercolorbox}[sep=0.0cm,ht=10mm,wd=\paperwidth]{frametitle}
\vbox{}\vskip-0ex%
\strut%
\ifnum\insertsectionstartframe=\insertsectionendframe%
\else%
\space(%
\ifnum\value{section}>0%
\textbullet%
\else%
\textopenbullet%
\fi%
}%
\fi%
)%
\fi%
\ifnum\thesubsection=0
\newline\hspace*{4mm}\small\strut\phantom{Pq}%
\else
\ifnum\insertsubsectionstartframe=\insertsubsectionendframe%
\else%
\space(%
\ifnum\insertsubsectionendframe<\insertsectionendframe
\else%
\fi%
\ifnum\value{section}>0%
\textbullet%
\else%
\textopenbullet%
\fi%
}%
\fi%
)%
\fi%
\fi%
\end{beamercolorbox}
}

\makeatletter
\CheckCommand*\beamer@checkframetitle{\@ifnextchar\bgroup\beamer@inlineframetitle{}}
\renewcommand*\beamer@checkframetitle{\global\let\beamer@frametitle\relax\@ifnextchar\bgroup\beamer@inlineframetitle{}}
\makeatother

\begin{document}

\part{Part1}

\section{Sec1}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textopenbullet\textopenbullet\textopenbullet\textopenbullet)\\[5mm]

\color{red}Note that when there is no subsection, no bullets should be shown.
\end{frame}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textopenbullet\textopenbullet\textopenbullet)\\[5mm]

\color{red}Note that when there is no subsection, no bullets should be shown.
\end{frame}

\subsection{Subsec1.1}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textbullet\textopenbullet\textopenbullet)\\
Subsec1.1 (\textbullet\textopenbullet)
\end{frame}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textbullet\textbullet\textopenbullet)\\
Subsec1.1 (\textbullet\textbullet)
\end{frame}

\subsection{Subsec1.2}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec1 (\textbullet\textbullet\textbullet\textbullet\textbullet)\\
Subsec1.2\\[5mm]
\color{red}Note that when there is only one frame in section or subsection, no bullets should be shown.
\end{frame}

\section{Sec2}

\subsection{Subsec2.1}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec2 (\textbullet\textopenbullet\textopenbullet)\\
Subsec2.1\\[5mm]
\color{red}Note that when there is only one frame in section or subsection, no bullets should be shown.
\end{frame}

\subsection{Subsec2.2}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec2 (\textbullet\textbullet\textopenbullet)\\
Subsec2.2 (\textbullet\textopenbullet)\\[5mm]

\color{red}I don't know why there is 3 bullets in the subsection here.
\end{frame}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec2 (\textbullet\textbullet\textbullet)\\
Subsec2.2 (\textbullet\textbullet)\\[5mm]

\color{red}I don't know why there is 3 bullets in the subsection here.
\end{frame}

\section{Sec3}

\begin{frame}
I would like to automatize the navigation bullets' in the frametitle and in the framesubtitle. Here that would give:\\[5mm]
Sec3\\[5mm]

\color{red}I don't know why there is 3 bullets in the subsection here.
\end{frame}

\end{document}

• I learned a lot from this. Awesome! – Bibi Sep 27 '18 at 21:28
• @Bibi You're welcome! And thanks for preparing such a nice MWE to start with. Having the desired output on each slide to compare was a huge help! – user36296 Sep 27 '18 at 21:35