[Tex/LaTex] Do not display empty subsection in beamer Warsaw theme

beamer

I have problem with empty subsections — they are added even, when I set them using \section*{}.

My MWE:

\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\usetheme{warsaw}
\setbeamercovered{transparent}
\begin{document}

\section{section 1}
\begin{frame}\end{frame}

\subsection{subsection 1}
\begin{frame}\end{frame}

\subsection{subsection 2}
\begin{frame}\end{frame}

\subsection{subsection 3}
\begin{frame}\end{frame}

\subsection{subsection 4}
\begin{frame}\end{frame}

\subsection*{}
\begin{frame}\end{frame}

\section{section 2}
\begin{frame}\end{frame}

\subsection{subsection 1}
\begin{frame}\end{frame}

\subsection{subsection 2}
\begin{frame}\end{frame}

\subsection{subsection 3}
\begin{frame}\end{frame}

\subsection{subsection 4}
\begin{frame}\end{frame}

\section{section 3}
\begin{frame}\end{frame}

\end{document}

In the navigation of section 1, there are 5 lines (last one has empty title), but in section 2, there are 4 lines.

How to force beamer not to add the last empty subsection? Empty section is not added to the navigation bar.

Section with 4 subsections and one empty subsection at the end:
Section with 4 subsections and one empty subsection at the end

Section with only 4 subsections:
Section with only 4 subsections

Best Answer

The following is similar to samcarter's answer but with an interface:

  • \stopnavigation turns off the beamer navigation;

  • \resumenavigation turns it back on again.

The above interface redefined \headcommand in the .nav file to temporarily do nothing, rather than write nothing to the .nav at all. It may not be ideal, but it works in your case:

\documentclass{beamer}
\let\Tiny\tiny% https://tex.stackexchange.com/q/58087/5764
\setbeamertemplate{navigation symbols}{}
\usetheme{Warsaw}
\setbeamercovered{transparent}

\makeatletter
\let\oldheadcommand\headcommand
\newcommand{\stopnavigation}{\addtocontents{nav}{\string\let\string\headcommand\string\@gobble}}
\newcommand{\resumenavigation}{\addtocontents{nav}{\string\let\string\headcommand\string\oldheadcommand}}
\makeatother

\begin{document}

\section{section 1}
\begin{frame}\end{frame}

\subsection{subsection 1}
\begin{frame}\end{frame}

\subsection{subsection 2}
\begin{frame}\end{frame}

\subsection{subsection 3}
\begin{frame}\end{frame}

\subsection{subsection 4}
\begin{frame}\end{frame}

\stopnavigation
\subsection*{}
\begin{frame}\end{frame}
\resumenavigation

\section{section 2}
\begin{frame}\end{frame}

\subsection{subsection 1}
\begin{frame}\end{frame}

\subsection{subsection 2}
\begin{frame}\end{frame}

\subsection{subsection 3}
\begin{frame}\end{frame}

\subsection{subsection 4}
\begin{frame}\end{frame}

\section{section 3}
\begin{frame}\end{frame}

\end{document}