2

I'd like to highlight the current section in my table of contents on all slides which are part of the section. At the moment the section is only highlighted on the slides without subsections. (Highlighting means for me the color of the section in the table of contents is white)

\documentclass{beamer}

% beamer theme
\usetheme{Marburg}

% german spelling
\usepackage[english,ngerman]{babel}

% set font encoding
\usepackage[T1]{fontenc}

% math stuff
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

% set fonts
\usepackage{xltxtra}
\usefonttheme{professionalfonts}
\setsansfont[
BoldFont={Helvetica Neue Medium},
ItalicFont={Helvetica Neue Italic},
BoldItalicFont={Helvetica Neue Medium Italic},
Ligatures=TeX
]{Helvetica Neue Light}
\setmonofont[Scale=0.9]{Menlo Regular}

% slide numbers in the bottom right corner
\setbeamertemplate{footline}{%
\hfill\usebeamertemplate***{navigation symbols}
\insertframenumber{}\hspace{3mm}\vspace{2mm}}



% removes navigation bar
\beamertemplatenavigationsymbolsempty

% color definitions
\definecolor{konzeBlue}{RGB}{45,170,250}
\definecolor{konzeBlueLight}{RGB}{116,199,252}
\definecolor{mainTextColor}{RGB}{80,80,80}
\definecolor{titleTextColor}{RGB}{120,120,120}

\makeatletter

% title page
\setbeamercolor{title}{fg=titleTextColor}
\setbeamercolor{author}{fg=mainTextColor}
\setbeamercolor{date}{fg=mainTextColor}

% sidebar
\setbeamertemplate{sidebar canvas right}[vertical shading][top=konzeBlue,bottom=konzeBlue]
\setbeamercolor{author in sidebar}{fg=white}
\setbeamercolor{section in sidebar}{fg=white}
\setbeamercolor{section in sidebar}{bg=konzeBlueLight}
\setbeamerfont{section in sidebar}{size=\tiny}
\setbeamerfont{section in sidebar}{series=\bfseries}
\setbeamercolor{subsection in sidebar}{fg=white}
\setbeamercolor{subsection in sidebar}{bg=konzeBlueLight}
\setbeamerfont{subsection in sidebar}{series=\tiny}

% slide number
\setbeamercolor{footline}{fg=white}

% frame
\setbeamercolor{frametitle}{fg=titleTextColor}
\makeatother


\title{Something}
\author{Max Mustermann}
\date{\today}

\begin{document}
\color{mainTextColor}

\section{Section}
\begin{frame}
    Section slide
\end{frame}

\subsection{Subsection}
\begin{frame}
\frametitle{Subsection Slide}
    Regular\\
    \textbf{Bold}\\
    \textit{Italic}\\
    \textit{\textbf{Bold Italic}}\\
    \texttt{Typewriter}\\
    \[\int_a^b x^2\mathrm{d}x\]
    This is $x$, $x$ is a variable.
\end{frame}

\end{document}

PS: I'm using xelatex for compilation

2

This can be done using a redefinition of \insertverticalnavigation to suppress a conditional (the lines commented out as marked using % NEW in the code below):

\documentclass{beamer}

% beamer theme
\usetheme{Marburg}

% redefinition of \insertverticalnavigation to get the desired highlighting for
% sections in the sidebar
\makeatletter
\def\insertverticalnavigation#1{%
  \vbox{%
    \def\sectionentry##1##2##3##4##5{%
      \ifnum##5=\c@part%
      \def\insertsectionhead{##2}%
      \def\insertsectionheadnumber{##1}%
      \def\insertpartheadnumber{##5}%
      \hbox{{%
        \usebeamerfont{section in sidebar}\usebeamercolor[fg]{section in sidebar}%
          \hyperlink{Navigation##3}{%
          \ifnum\c@section=##1%
            %\ifnum\c@subsection=0\relax% NEW
              {\usebeamertemplate{section in sidebar}}%
            %\else%% NEW
              \ifx\beamer@nav@css\beamer@hidetext%
                {\usebeamertemplate{section in sidebar}}%
              \else%
                {\usebeamertemplate{section in sidebar shaded}}%
              \fi%
            %\fi%% NEW
          \else
            {\usebeamertemplate{section in sidebar shaded}}%
          \fi}}}%
      \beamer@currentsubsection=0\relax\fi}%
    \def\slideentry##1##2##3##4##5##6{}%
    \def\beamer@subsectionentry##1##2##3##4##5{%
      \ifnum##1=\c@part%
      \def\insertpartheadnumber{##1}%
      \def\insertsectionheadnumber{##2}%
      \def\insertsubsectionheadnumber{##3}%
      \def\insertsubsectionhead{##5}%
       \beamer@tocifnothide{\ifnum\c@section=##2\ifnum\c@subsection=##3\beamer@nav@css\else\beamer@nav@oss\fi\else\beamer@nav@ooss\fi}%
      {\hbox{{%
        \usebeamerfont{subsection in sidebar}\usebeamercolor[fg]{subsection in sidebar}%
          \hyperlink{Navigation##4}{%
          \ifnum\c@section=##2%
            \ifnum\c@subsection=##3%
              \ifnum\c@subsubsection=0\relax%
                {\usebeamertemplate{subsection in sidebar}}%
              \else%
                {\usebeamertemplate{subsection in sidebar shaded}}%
              \fi%
            \else%
              {\usebeamertemplate{subsection in sidebar shaded}}%
            \fi%
          \else%
            {\usebeamertemplate{subsection in sidebar shaded}}%
          \fi}}}%
      }%
      \fi}%
    \def\beamer@subsubsectionentry##1##2##3##4##5##6{%
      \ifnum##1=\c@part%
      \def\insertpartheadnumber{##1}%
      \def\insertsectionheadnumber{##2}%
      \def\insertsubsectionheadnumber{##3}%
      \def\insertsubsubsectionheadnumber{##3}%
      \def\insertsubsubsectionhead{##6}%
      \beamer@tocifnothide{\ifnum\c@section=##2\ifnum\c@subsection=##3\beamer@nav@css\else\beamer@nav@oss\fi\else\beamer@nav@ooss\fi}%
      {\hbox{{%
        \usebeamerfont{subsubsection in sidebar}\usebeamercolor[fg]{subsubsection in sidebar}%
          \hyperlink{Navigation##5}{%
          \ifnum\c@section=##2%
            \ifnum\c@subsection=##3%
              \ifnum\c@subsubsection=##4%
                {\usebeamertemplate{subsubsection in sidebar}}%
              \else
                {\usebeamertemplate{subsubsection in sidebar shaded}}%
              \fi%
            \else%
              {\usebeamertemplate{subsubsection in sidebar shaded}}%
            \fi%
          \else%
            {\usebeamertemplate{subsubsection in sidebar shaded}}%
          \fi}}}%
      }%
      \fi}%
    %\beamer@currentsubsection=0\relax%
    \dohead%
  }%
}
\makeatother
% german spelling
\usepackage[english,ngerman]{babel}

% set font encoding
\usepackage[T1]{fontenc}

% math stuff
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

% set fonts
\usepackage{xltxtra}
\usefonttheme{professionalfonts}
%\setsansfont[
%BoldFont={Helvetica Neue Medium},
%ItalicFont={Helvetica Neue Italic},
%BoldItalicFont={Helvetica Neue Medium Italic},
%Ligatures=TeX
%]{Helvetica Neue Light}
%\setmonofont[Scale=0.9]{Menlo Regular}

% slide numbers in the bottom right corner
\addtobeamertemplate{footline}{%
\hfill\usebeamertemplate***{navigation symbols}
\insertframenumber{}\hspace{3mm}\vspace{2mm}}{}

% removes navigation bar
\beamertemplatenavigationsymbolsempty

% color definitions
\definecolor{konzeBlue}{RGB}{45,170,250}
\definecolor{konzeBlueLight}{RGB}{116,199,252}
\definecolor{mainTextColor}{RGB}{80,80,80}
\definecolor{titleTextColor}{RGB}{120,120,120}

\makeatletter

% title page
\setbeamercolor{title}{fg=titleTextColor}
\setbeamercolor{author}{fg=mainTextColor}
\setbeamercolor{date}{fg=mainTextColor}

% sidebar
\setbeamertemplate{sidebar canvas right}[vertical shading][top=konzeBlue,bottom=konzeBlue]
\setbeamercolor{author in sidebar}{fg=white}
\setbeamercolor{section in sidebar}{fg=white}
\setbeamercolor{section in sidebar}{bg=konzeBlueLight}
\setbeamerfont{section in sidebar}{size=\tiny}
\setbeamerfont{section in sidebar}{series=\bfseries}
\setbeamercolor{subsection in sidebar}{fg=white}
\setbeamercolor{subsection in sidebar}{bg=konzeBlueLight}
\setbeamerfont{subsection in sidebar}{series=\tiny}

% slide number
\setbeamercolor{footline}{fg=white}

% frame
\setbeamercolor{frametitle}{fg=titleTextColor}
\makeatother


\title{Something}
\author{Max Mustermann}
\date{\today}

\begin{document}
\color{mainTextColor}

\section{Test section one}
\begin{frame}
test
\end{frame}

\subsection{Test subsection}
\begin{frame}
test
\end{frame}

\subsection{Test subsection}
\begin{frame}
test
\end{frame}

\section{Test section two}
\begin{frame}
test
\end{frame}

\subsection{Test subsection}
\begin{frame}
test
\end{frame}

\subsection{Test subsection}
\begin{frame}
test
\end{frame}

\end{document}

enter image description here

I commented out the lines using the Helvetica fonts since I don't have that font in my system, but that's irrelevant for the solution.

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.