[Tex/LaTex] Navigation to section/subsection from Beamer headline titles

beamerthemes

Beamer infolines themes, like CambridgeUS, insert the titles of the current section and subsection in the headline. These titles appear to be clickable (the screen pointer changes as if they were so) but nothing happens when one clicks them.

Is there a way to link the headline titles to the first frame of the corresponding section or subsection? Something like this already works on the theme footline: clicking on the presentation title takes you to the title page.

Edit: MWE

\documentclass{beamer}
\usetheme{CambridgeUS} 
\setbeamertemplate{navigation symbols}{}
\title{Click on Headline}
\author{A.~U.~Thor}
\institute{X-University}
\date{2015}
\begin{document}
\begin{frame}
  \titlepage
\end{frame}
\begin{frame}[t]{Contents}
  \tableofcontents[subsectionstyle=hide] 
\end{frame}
\section{Section 1}
\begin{frame}{Section 1}
  \centering \Large Section 1
\end{frame}
\begin{frame}[t]{Section 1: Contents}
  \tableofcontents[currentsection,hideothersubsections]
\end{frame}
\subsection{Subsection 1.1}
\begin{frame}{Frame 1.1.1}
  A frame of subsection 1.1
\end{frame}
\begin{frame}{Frame 1.1.2}
  Another frame of subsection 1.1
\end{frame}
  \subsection{Subsection 1.2}
\begin{frame}{Frame 1.2.1}
  A frame of subsection 1.2
\end{frame}
\begin{frame}{Frame 1.2.2}
  Another of subsection 1.2
\end{frame}
\section{Section 2}
\begin{frame}{Section 2}
  \centering \Large Section 2
\end{frame}
\begin{frame}[t]{Section 2: Contents}
  \tableofcontents[currentsection,hideothersubsections]
\end{frame}
\subsection{Subsection 2.1}
\begin{frame}{Frame 2.1.1}
  A frame of subsection 2.1
\end{frame}
\end{document}

Best Answer

This is a bug in beamer and will be fixed in the next release. In beamerbasesection.sty you'll find the rather long definition for \beamer@section. It has

\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}%

This means that when the hyperlink is inserted it refers to the current page, not the first page of the section. The code should read

\protected@edef\insertsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{#1}}%

This forces \the\c@page to expand to it's value (the LaTeX idiom here should really be \thepage). With that change and a similar one for subsections everything works as it should.

For the present, a fix can be applied using \patchcmd

\documentclass{beamer}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\beamer@section}
  {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}}
  {\protected@edef\insertsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{#1}}}
  {}{}
\patchcmd{\beamer@subsection}
  {\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{#1}}}
  {\protected@edef\insertsubsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{#1}}}
  {}{}
\makeatother
% etc.