2

The default beamer template shows only the subsection in the headline. I would like it to show the section as well as the subsection. It can be done by changing the theme to infolines etc, but I prefer to use the default theme and just add the section name in the headline.

Here is how the original frame looks: Original frame

Here is how I want it: Desired frame

MWE:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

%Modify theme
\setbeamertemplate{navigation symbols}{} %get rid of navigation symbols
\setbeamertemplate{sections/subsections in toc}[ball unnumbered] %bullets in table of contents should be balls
\setbeamertemplate{itemize items}[ball] %bullets in frames should be balls

\title{My title}
\author{My name}
\institute{My institute}
\date{\today}

\begin{document}

\maketitle

\begin{frame}{Outline}
\tableofcontents
\end{frame}

\section{Section 1}

\begin{frame}{Section 1}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}

\section{Section 2}
\subsection{Subsection 2.1}
\begin{frame}{Subsection 2.1}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}

\subsection{Subsection 2.2}
\begin{frame}{Subsection 2.2}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}

\end{document}
3
  • But you are manually using the section as the frame title. Why? Will alll your frames have as title the title of the section? Jul 8, 2015 at 14:06
  • You are right. Very silly of me. I replaced \begin{frame}{Subsection 2.1} with \begin{frame}{\insertsection \hfill \insertsubsection}. This already heads in the correct direction. Thank you. It still does not put the subsection at the top right corner. And yes, all frames will have the title as title of section. Jul 8, 2015 at 14:15
  • See my answer for an automatic solution. Jul 8, 2015 at 14:19

1 Answer 1

4

One possibility is to (re)define an appropriate template (the sensible candidates are headline or frame title) to use \insertsectionhead and \insertsubsectionhead:

enter image description here

The code:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

%Modify theme
\setbeamertemplate{navigation symbols}{} %get rid of navigation symbols
\setbeamertemplate{sections/subsections in toc}[ball unnumbered] %bullets in table of contents should be balls
\setbeamertemplate{itemize items}[ball] %bullets in frames should be balls

\setbeamertemplate{headline}{%
  \leavevmode%
  \begin{beamercolorbox}[sep=0.3cm,wd=\paperwidth]{section in head/foot}%
  \usebeamercolor[fg]{structure}\Large\insertsectionhead\hfill\insertsubsectionhead%  
  \end{beamercolorbox}%
}

\title{My title}
\author{My name}
\institute{My institute}
\date{\today}

\begin{document}

\maketitle

\begin{frame}{Outline}
\tableofcontents
\end{frame}

\section{Section 1}

\begin{frame}
\frametitle{Title for the frame}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}

\section{Section 2}
\subsection{Subsection 2.1}
\begin{frame}
\frametitle{Title for the frame}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}

\subsection{Subsection 2.2}
\begin{frame}
\frametitle{Title for the frame}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}

\end{document}
1
  • This works perfectly. I don't even need to add frame titles. Beautiful! Thank you very much for quick answer. I am unable to vote your answer up because my reputaion is <15 :( Jul 8, 2015 at 14:23

You must log in to answer this question.

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