4

I want to show Section and subsection names in the footnote of a presentation, made by beamer. Now, in the footer, I am using

\insertsection\text{ $\quad \mid \quad $ }\insertsubsection

to create something like "Section title | subsection title"

However, for the sections without any subsection, I will still have "|" in the footnote.

Is there any way to insert "|" after section title if only there is a subsection title to be reported after that?

3
  • Which theme are you using? Sep 4, 2015 at 18:26
  • \usetheme{default}
    – Jeff
    Sep 4, 2015 at 18:28
  • 1
    You can do a conditional test to decide whether or not to include the subsection titles: \makeatletter \setbeamertemplate{footline}{\leavevmode \vbox{\begin{beamercolorbox}[dp=1.5ex]{fg=black} \hspace*{1em}\insertsectionhead\ifx\insertsubsectionhead\@empty\relax\else\,|\,\insertsubsectionhead\fi \end{beamercolorbox}}} \makeatother Sep 4, 2015 at 18:41

1 Answer 1

4

You can do a conditional test to decide whether or not to include the subsection titles; something along these lines:

\insertsectionhead
  \ifx\insertsubsectionhead\@empty\relax\else$\quad\mid\quad$\insertsubsectionhead\fi

A complete example (to diaply the information I used a beamercolorbox and the footline template, but this is optional; use the settings that best adjust to your needs):

\documentclass{beamer}

\makeatletter
\setbeamertemplate{footline}{%
\leavevmode
\vbox{\begin{beamercolorbox}[dp=1.25ex,ht=2.75ex]{fg=black}%
  \hspace*{1em}\insertsectionhead%
  \ifx\insertsubsectionhead\@empty\relax\else$\quad\mid\quad$\insertsubsectionhead\fi
  \end{beamercolorbox}%
  }%
}
\makeatother

\begin{document}

\section{Test section One}
\begin{frame}
test
\end{frame}
\subsection{Test subsection One One}
\begin{frame}
test
\end{frame}
\subsection{Test subsection One Two}
\begin{frame}
test
\end{frame}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .