1

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.

enter image description here

2

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}

\setbeamertemplate{section in sidebar}{\tikz{\node[fill=black!80,text=white]{\insertsectionhead};}}

\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}

enter image description here

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
\patchcmd{\insertverticalnavigation}%
{\ifx\beamer@nav@css\beamer@hidetext{\usebeamertemplate{section in sidebar}}\else{\usebeamertemplate{section in sidebar shaded}}\fi}%
{{\usebeamertemplate{section in sidebar}}}{}{}
\makeatother
| improve this answer | |
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.