1

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?

3

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}
  • Thank you. It is working for sections. Is there a way to use this for subsections, too? – epR8GaYuh Jun 26 '17 at 12:17
  • 1
    @epR8GaYuh sure, please see my edit – user36296 Jun 26 '17 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.