9

In a Beamer presentation, the general TOC is long. So, I wouldn't like to show all the TOC with all the sections and subsections at once. Intead, I would like to show the TOC with pausesections option, but showing only the subsections of the current section.

The idea I have is like the next dynamic list, with the command \only<+>

This is the MWE:

\documentclass{beamer}

\begin{document}

\begin{frame}

\begin{itemize}[<+->]
\item Section 1
\item Section 2 \\
\only<+>{
sub-section 2.1 \\
sub-section 2.2 \\
sub-section 2.3}
\item Section 3 \\
\only<+>{
sub-section 3.1 \\
sub-section 3.2 \\
sub-section 3.3}
\item Section 4
\end{itemize}

\end{frame}

\end{document}
15

Three pieces of code are given below

  1. Subsections visible only when section entry revealed
  2. Subsections visible once only after section entry is revealed
  3. Subsections only visible for current section

Subsections visible only when section entry revealed

The following is very close to what you ask - the subsections will appear on the same slide as the corresponding section is revealed rather than on the slide after. See the section below, for how to get the other behaviour. The screen shots are for the second and third views of the contents page:

Sample second page

Sample third page

\documentclass{beamer}

\usetheme{Warsaw}

\makeatletter
\def\beamer@tocaction@only#1{\only<.(1)>{\usebeamertemplate**{#1}}}
\define@key{beamertoc}{subsectionsonly}[]{\beamer@toc@subsectionstyle{show/only}\beamer@toc@subsubsectionstyle{show/shaded/hide}}
\makeatother

\begin{document}
\AtBeginSection[]{\begin{frame}{Outline}
  \tableofcontents[subsectionsonly, pausesections] 
\end{frame}}

\section{One}
\begin{frame}
  \frametitle{ff}

\end{frame}
\section{Two}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Two a}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Two b}
\begin{frame}
  \frametitle{ff}

\end{frame}

\section{Three}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Three a}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Three b}
\begin{frame}
  \frametitle{ff}

\end{frame}

\end{document}

The code adds an extra key type only to effect the insertion of an appropriate \only overlay command. This is packaged up in a new key subsectionsonly to \tableofcontents.

Subsections visible once only after section entry is revealed

Inserting an extra pause between the display of the section and that of the subsections, is a bit more involved. One needs to rewrite the functions \beamer@tableofcontents and \beamer@subsectionintoc. This is probably best done via patching of the commands, as below. The screeshots are for the first page revealing section 3 and for the next page:

Sample page w/o subsections

Sample page with subsections

\documentclass{beamer}

\usetheme{Warsaw}

\usepackage{etoolbox}

\makeatletter
\def\beamer@tocaction@only#1{\only<.(1)>{\usebeamertemplate**{#1}}}
\define@key{beamertoc}{subsectionsonly}[]{\beamer@toc@subsectionstyle{show/only}\beamer@toc@subsubsectionstyle{show/shaded/hide}}

\newif\ifbeamer@pausebeforesubsections
\define@key{beamertoc}{pausebeforesubsections}[true]{\beamer@pausebeforesubsectionstrue}

\patchcmd{\beamer@tableofcontents}{\beamer@pausesectionsfalse}%
  {\beamer@pausesectionsfalse\beamer@pausebeforesubsectionsfalse}{}{}

\patchcmd{\beamer@subsectionintoc}{\ifbeamer@pausesubsections\pause\fi}%
  {\ifbeamer@pausesubsections\pause\else%
   \ifbeamer@pausebeforesubsections\ifnumequal{#2}{1}{\pause}{}\fi\fi}{}{}
\makeatother

\begin{document}
\begin{frame}{Outline}
  \tableofcontents[subsectionsonly,pausebeforesubsections,pausesections] 
\end{frame}

\section{One}
\begin{frame}
  \frametitle{ff}

\end{frame}
\section{Two}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Two a}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Two b}
\begin{frame}
  \frametitle{ff}

\end{frame}

\section{Three}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Three a}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Three b}
\begin{frame}
  \frametitle{ff}

\end{frame}

\end{document}

The above code includes that of the first example and adds a new option pausebeforesubsections, which inserts a \pause before the block of subsections. This is only necessary if pausesubsections is not set. By default pausebeforesubsections is set to false.

Subsections only visible for current section

Use the hideothersubsections option. The code below gives the following table of contents at the beginning of section three, even though section two has subsections:

Sample output

\documentclass{beamer}

\usetheme{Warsaw}

\begin{document}
\AtBeginSection[]{\begin{frame}{Outline}
  \tableofcontents[hideothersubsections, pausesections] 
\end{frame}}

\section{One}
\begin{frame}
  \frametitle{ff}

\end{frame}
\section{Two}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Two a}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Two b}
\begin{frame}
  \frametitle{ff}

\end{frame}

\section{Three}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Three a}
\begin{frame}
  \frametitle{ff}

\end{frame}

\subsection{Three b}
\begin{frame}
  \frametitle{ff}

\end{frame}

\end{document}

See section 10.5 of the beamer manual for further options to control what is and is not visible.

  • Thanks, this is not what I have in the head. I have already edited the questions with a MWE. – Gitano May 25 '13 at 18:43
  • Thanks! It works perfect. This is exactly I had in my mind. – Gitano May 25 '13 at 22:49

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.