I've ported from PowerPoint my university's template in Beamer, and added some code to display sections (and subsections when they exists) in the header.
This is the code snippet I've put in the headline
template for this purpose:
\begin{beamercolorbox}[wd=0.6\paperwidth,ht=0.1\beamer@PoliMI@headheight]{section in head/foot}%
\usebeamerfont{section in head/foot}\par%
\vfill\strut\insertsectionhead%
\ifx\insertsubsection\empty\else%
~--~\insertsubsectionhead%
\fi%
\strut\par%
\end{beamercolorbox}\\%
However, when "exiting" from subsection (issuing \subsection*{}
), the dash after the section name is still printed.
How can I test if the subsection name is void?
As an alternative, how can I make \insertsubsection
empty?
MWE:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}\normalfont
\usepackage[T1]{fontenc}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{headline}{%
\begin{beamercolorbox}[wd=0.6\paperwidth,ht=0.016\paperwidth]{section in head/foot}%
\usebeamerfont{section in head/foot}%
\par\vfill\strut\insertsectionhead%
\ifx\insertsubsection\empty\else~--~\insertsubsectionhead%
\fi\strut\par%
\end{beamercolorbox}%
}
\begin{document}
\section{aaa}
\begin{frame}~\end{frame}
\subsection{bbb}
\begin{frame}~\end{frame}
\subsection*{}
\begin{frame}~\end{frame}
\end{document}
In the third frame, only "aaa" must show up, and not "aaa -".
UPDATE: If subsection is not yet defined, \insertsubsection
is empty, whereas if a \subsection*{}
is issued, the macro is expanded in \expandafter \hyperlink \subsectionlink
, either the subsection is empty (\insertsubsectionhead
expands to \hyperlink {Navigation\the \c@page }{}
) or not (\insertsubsectionhead
expands to \hyperlink {Navigation\the \c@page }{bbb}
in the second frame).
\documentclass
and the appropriate packages so that those trying to help don't have to recreate it. It is still going to be useful in testing that a proposed solution actually worked.