3

I have a ToC with 5 sections, and I want 5 frames where there is on each one a table of contents with the ith section highlighted, and the other are shaded.

What I have so far is the following :

\documentclass{beamer}
\usetheme{Madrid}

\begin{document}
\begin{frame}{Overview} 
  \only<1>{
    \tableofcontents[sections={1}]
    \tableofcontents[sections={2-5},sectionstyle=shaded,subsectionstyle=shaded]
  }
  \only<2>{
    \tableofcontents[sections={1},sectionstyle=shaded,subsectionstyle=shaded]
    \tableofcontents[sections={2}]
    \tableofcontents[sections={3-5},sectionstyle=shaded,subsectionstyle=shaded]
  }
  \only<3>{
    \tableofcontents[sections={1,2},sectionstyle=shaded,subsectionstyle=shaded]
    \tableofcontents[sections={3}]
    \tableofcontents[sections={4-5},sectionstyle=shaded,subsectionstyle=shaded]
  }
  \only<4>{
    \tableofcontents[sections={1-3},sectionstyle=shaded,subsectionstyle=shaded]
    \tableofcontents[sections={4}]
    \tableofcontents[sections={5},sectionstyle=shaded,subsectionstyle=shaded]
  }
  \only<5>{
    \tableofcontents[sections={1-4},sectionstyle=shaded,subsectionstyle=shaded]
    \tableofcontents[sections={5}]
  }
\end{frame}

\section{Section 1}
\begin{frame}{Frame 1}
\end{frame}

\section{Section 2}
\begin{frame}{Frame 2}
\end{frame}

\section{Section 3}
\begin{frame}{Frame 3}
\end{frame}

\section{Section 4}
\begin{frame}{Frame 4}
\end{frame}

\section{Section 5}
\begin{frame}{Frame 5}
\end{frame}

\end{document}

I wonder whether there is a better way to do that ?

Thanks

  • 1
    Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – user36296 Nov 28 '15 at 13:45
  • You're right ! I have update my code. – dooxe Nov 28 '15 at 13:52
  • A similar automatic approach might be \begin{frame} \setbeamercovered{transparent} \tableofcontents[pausesections] \end{frame}. Unfortunately I do not know how to recover the sections again. In your manual approach you should keep an eye on the spacing - every time you call \tableofcontents additional space is added thus making the spacing inhomogeneous. – user36296 Nov 28 '15 at 15:11
  • I tried your solution thanks. The problem is that my ToC is too dense, and at the end not so readable with all the items higlighted. That is why I just want one item be visible at time. – dooxe Nov 28 '15 at 22:08
6

After your \begin{document} put this code. It shall do it:

\begin{frame}
\titlepage
\end{frame}

\begin{frame}
\frametitle{Plan}
\tableofcontents[pausesections]
\end{frame}

\AtBeginSection[]{

\begin{frame}
\frametitle{Plan}
\tableofcontents[currentsection]
\end{frame}}
3

You may use the currentsection option and set a temporary value in the section counter.

\documentclass{beamer}
\usetheme{Madrid}
\newcommand\tocforsect[2]{%
  \begingroup
  \edef\safesection{\thesection}
  \setcounter{section}{#1}
  \tableofcontents[#2,currentsection]
  \setcounter{section}{\safesection}
  \endgroup
}
\begin{document}
\begin{frame}{Overview}
  \only<1>{\tocforsect{1}{sectionstyle=shaded,subsectionstyle=shaded}}
  \only<2>{\tocforsect{2}{sectionstyle=shaded,subsectionstyle=shaded}}
  \only<3>{\tocforsect{3}{sectionstyle=shaded,subsectionstyle=shaded}}
  \only<4>{\tocforsect{4}{sectionstyle=shaded,subsectionstyle=shaded}}
  \only<5>{\tocforsect{5}{sectionstyle=shaded,subsectionstyle=shaded}}
\end{frame}
\section{Section 1}
\begin{frame}{Frame 1}
\end{frame}

\section{Section 2}
\begin{frame}{Frame 2}
\end{frame}

\section{Section 3}
\begin{frame}{Frame 3}
\end{frame}

\section{Section 4}
\begin{frame}{Frame 4}
\end{frame}

\section{Section 5}
\begin{frame}{Frame 5}
\end{frame}

\end{document}
3
+50

For a normal list that's easy:

\setbeamercovered{transparent}% see beamer documentation p 190
\beamerdefaultoverlayspecification{<+>}% see beamer documentation p 89

Unfortunately, that does not work with \tableofcontents[pausesections] because this is internally using the far less powerful \pause command.

So I have tried to redefine the \pause command to call \onslide with an overlay specification that is desirable for our purpose. Actually, according to the beamer documentation page 78 \pause usually does use \onslide internally already.

However, it does not seem possible to define commands with parameters inside of a frame (and \pause has one optional parameter, again see beamer documentation page 78) and \pause is overridden at the beginning of a frame.

Consequently I am defining a new command in front of the frame and \let it inside of it:

\documentclass{beamer}
\usetheme{Madrid}

\newcommand{\mypause}[1][+]{\onslide<#1>}
\begin{document}
\begin{frame}{Overview} 
    \setbeamercovered{transparent}% doc p 190
    \let\pause\mypause
    \tableofcontents[pausesections]
\end{frame}

\section{Section 1}
\begin{frame}{Frame 1}
\end{frame}

\section{Section 2}
\begin{frame}{Frame 2}
\end{frame}

\section{Section 3}
\begin{frame}{Frame 3}
\end{frame}

\section{Section 4}
\begin{frame}{Frame 4}
\end{frame}

\section{Section 5}
\begin{frame}{Frame 5}
\end{frame}

\end{document}
  • That's great! I guess this is also applicable to tex.stackexchange.com/questions/252182/…. Would you like to answer this? – user36296 Dec 26 '16 at 22:41
  • @samcarter yes, thank you. I have answered it. – jakun Dec 27 '16 at 9:49
  • 3
    To define \mypause inside a frame, you may use \newcommand\mypause[1][+]{\onslide<####1>}. – Paul Gaborit Dec 27 '16 at 11:28
0
\documentclass{beamer}
\usetheme{Madrid}

\begin{document}
\begin{frame}{Contents} 
\tableofcontents
\end{frame}

\section{Section 1}
\tableofcontents[currentsection]
\begin{frame}{Frame 1.1}
\end{frame}
\begin{frame}{Frame 1.2}
\end{frame}
\begin{frame}{Frame 1.3}
\end{frame}
\section{Section 2}
\tableofcontents[currentsection]
\begin{frame}{Frame 2.1}
\end{frame}
\begin{frame}{Frame 2.2}
\end{frame}
\begin{frame}{Frame 2.3}
\end{frame}
\section{Section 3}
\tableofcontents[currentsection]
\begin{frame}{Frame 3.1}
\end{frame}
\begin{frame}{Frame 3.2}
\end{frame}
\begin{frame}{Frame 3.3}
\end{frame}
\section{Section 4}
\tableofcontents[currentsection]
\begin{frame}{Frame 4.1}
\end{frame}
\begin{frame}{Frame 4.2}
\end{frame}
\begin{frame}{Frame 4.3}
\end{frame}
\section{Section 5}
\tableofcontents[currentsection]
\begin{frame}{Frame 5.1}
\end{frame}
\begin{frame}{Frame 5.2}
\end{frame}
\begin{frame}{Frame 5.3}
\end{frame}
\end{document}

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.