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}
Best Answer
Three pieces of code are given below
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:
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 keysubsectionsonly
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: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 ifpausesubsections
is not set. By defaultpausebeforesubsections
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:See section 10.5 of the beamer manual for further options to control what is and is not visible.