# Adding background color to active sections of beamer sidebar

I have designed a theme for my beamer presentation which has sidebar in it. Now I want to add background color for active items in the sidebar. How can I do that?

Following picture shows what I intend to do.

Since you are not providing a MWE I'm using a standard sidebar theme to show what you need to do in principle. If you need something more specific for your use case please provide a MWE with your code.

\documentclass{beamer}
\usepackage{tikz}
\usetheme{Hannover}

\begin{document}
\section{first}
\begin{frame}
this is a test
\end{frame}
\section{second}
\begin{frame}
this is a test 2
\end{frame}
\end{document}


You can customize the appearance as much as you like by styling the TikZ node.

If you also want sections to be highlighted when there are subsections (by default Beamer shades a section when it has subsections), you need to add the following code to your preamble (kindly provided by @diabonas)

\usepackage{etoolbox}
\makeatletter

• This does not work well when the section title is longer than the width of the sidebar -- then the section title in the tikz node is not properly wrapped. It gets even worse when changing the size of the font, e.g. \setbeamerfont{section in sidebar}{size=\fontsize{10}{10}\selectfont} -- then the position of the section title changes as well. Do you know of any simple fixes for these cases? – dolphin Jan 8 at 11:14