[Tex/LaTex] highlight both section and subsection in the outline on the side of a beamer slide

beamer

Currently only subsection highlighted on the outline on the side of the slide. Is it possible to change the template so when in a subsection the respective section stays highlighted.

\documentclass{beamer}
\mode<presentation>{\usetheme{Hannover}}
\begin{document}
\section{1}
\subsection{a}
\begin{frame}
stuff
\end{frame}
\subsection{b}
\begin{frame}
more stuff
\end{frame}
\end{document}

Best Answer

This behaviour is not limited to the theme Hannover, it concerns all themes using sidebars. To change it, you have to patch the macro \insertverticalnavigation, which is responsible for generating the sidebar navigation:

\documentclass{beamer}
\mode<presentation>{\usetheme{Hannover}}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\insertverticalnavigation}%
{\ifx\beamer@nav@css\beamer@hidetext{\usebeamertemplate{section in sidebar}}\else{\usebeamertemplate{section in sidebar shaded}}\fi}%
{{\usebeamertemplate{section in sidebar}}}{}{}
\makeatother

\begin{document}
\section{1}
\subsection{a}\frame{}
\subsection{b}\frame{}
\section{2}
\subsection{a}\frame{}
\subsection{b}\frame{}
\end{document}

The code in ll. 4-9 changes the default behaviour of beamer to always highlight the current section (with the beamer theme section in sidebar in contrast to section in sidebar shaded) - normally, the section is only highlighted if no subsections are shown in the sidebar, i.e. if you have \usetheme[hideallsubsections]{Hannover}.

The resulting sidebar with highlighted section (cropped):

sidebar with section "1" and subsection "b" highlighted