[Tex/LaTex] Redrawing beamer navigation (\insertnavigation) from frame environment

beamermini-framesnavigation

I need to highlight specific entries of my beamer navigation according to highlighted entries within an overview figure. For this purpose, I need to redraw the navigation from within the frame environment. The problem: The current solution requires a manual adjustment of the alignment. What can be considered as hacky. A cleaner solution for the exact alignment at the original position would be highly appreciated. Big thx in advance for your ideas and suggestions!

Result without intentionally bad manual alignment.

\documentclass[t]{beamer}

\usetheme{Singapore}
\useoutertheme{miniframes}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\section{Section}
\subsection{Subsection}

\begin{frame}[c]
\frametitle{Title}
\framesubtitle{Subtitle}
%
\begin{beamerboxesrounded}[]{}
The intention is to redraw the navigation from \emph{within} the frame environment to e.\,g. allow highlights of specific sections. The problem: The current solution needs a manual adjustment of the alignment. What can be considered as hacky. A cleaner solution for the \emph{exact} alignment at the original position would be highly appreciated.
\end{beamerboxesrounded}
%
\begin{tikzpicture}[remember picture,overlay]%
{\node[anchor=north west,text width=\paperwidth] at ($(current page.north west) + (0ex,0ex)$) {%
\begin{beamercolorbox}[ignorebg,wd=\paperwidth]{section in head/foot}%
\usebeamerfont{headline}\insertnavigation{\paperwidth}%
\end{beamercolorbox}};}%
\end{tikzpicture}
%
\end{frame}

\end{document}

Best Answer

Partial solution

The following code reduces the manual spacing to only one dimension, but unless you use some technique like \tikzmark to actually record the position of the navigation bar, adjusting the spacing in vertical direction seems necessary, as the original navigation bar is not on the very top of the frame.

The original definition of the headline in the miniframe theme is

\defbeamertemplate*{headline}{miniframes theme}
{%
  \begin{beamercolorbox}[colsep=1.5pt]{upper separation line head}
  \end{beamercolorbox}
  \begin{beamercolorbox}{section in head/foot}
    \vskip2pt\insertnavigation{\paperwidth}\vskip2pt
  \end{beamercolorbox}%
  \ifbeamer@theme@subsection%
    \begin{beamercolorbox}[colsep=1.5pt]{middle separation line head}
    \end{beamercolorbox}
    \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
      leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
      \usebeamerfont{subsection in head/foot}\insertsubsectionhead
    \end{beamercolorbox}%
  \fi%
  \begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
  \end{beamercolorbox}
}

As you can see, this definition includes

  • manual spacing, e.g. the \vskip2pt
  • a separation line at the top of the frame and
  • the margins of the colorboxes

This space has to be somehow compensated.

\documentclass[t]{beamer}

\usetheme{Singapore}
\useoutertheme{miniframes}

\usepackage{tikz}
\usetikzlibrary{calc,positioning}

\begin{document}

\section{Section}
\subsection{Subsection}

\section{Section}
\subsection{Subsection}

\begin{frame}[c]
\frametitle{Title}
\framesubtitle{Subtitle}
%
\begin{beamerboxesrounded}[]{}
The intention is to redraw the navigation from \emph{within} the frame environment to e.\,g. allow highlights of specific sections. The problem: The current solution needs a manual adjustment of the alignment. What can be considered as hacky. A cleaner solution for the \emph{exact} alignment at the original position would be highly appreciated.
\end{beamerboxesrounded}
\begin{tikzpicture}[remember picture,overlay]%
{\node[text width=\paperwidth] at (current page.north) {%
    \vskip13.25pt%
    \usebeamerfont{headline}\insertnavigation{\paperwidth}%
};
}%
\end{tikzpicture}
\end{frame}

\end{document}

enter image description here