2

I am trying to use a section at the end of a presentation without any frames for it as shown in the following MWE:

\documentclass{beamer}

\begin{document}

\begin{frame}{TOC}
\tableofcontents
\end{frame}

\section{The first section}

\begin{frame}
Some text.
\end{frame}

\section{The second section}

\end{document}

This produces a TOC which only consists of the The first section. I want to get a TOC which additionally shows The second section.

I could use a dummy frame for the second section of course, but is there any way to avoid adding a frame for the second section?

1 Answer 1

4

Based on https://tex.stackexchange.com/a/10297/36296

The problem is that without another page following, the content is not written to the toc file. You can circumvent the problem like this:

\documentclass{beamer}

\makeatletter
\newcommand\immaddtocontents[1]{{%
   \let\protect\@unexpandable@protect
   \immediate\write\@auxout{\noexpand\@writefile{toc}{#1}}%
}}
\makeatother


\begin{document}

\begin{frame}{TOC}
\tableofcontents
\end{frame}

\section{The first section}
\subsection{blub}

\begin{frame}
Some text.
\end{frame}

\section{The first section}
\subsection{blub}

\begin{frame}
Some text.
\end{frame}

\immaddtocontents{\vfill \protect\usebeamercolor[fg]{section in toc} text\par}

\immaddtocontents{\leavevmode\leftskip=1.5em \protect\usebeamercolor[fg]{normal text}text\par}

\end{document}
2
  • Thank you. It is working for sections. Is there a way to use this for subsections, too?
    – epR8GaYuh
    Commented Jun 26, 2017 at 12:17
  • 1
    @epR8GaYuh sure, please see my edit Commented Jun 26, 2017 at 12:23

You must log in to answer this question.

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