1

I have a problem with beamer. I would like to activate the TOC with just the current section and subsection every time a new subsection starts (I can already handle the case of activating the current section with all subsections at the beginning of every section). Below a MWE.

\documentclass{beamer}
 
\usetheme{CambridgeUS}
\usepackage[english]{babel}

\title[Title]{Title}
\author[Author]{Author}
\institute{Institute}
\date[21/10/1985]{21/10/1985}

\AtBeginSection[]
{
  \begin{frame}<beamer>
    \frametitle{Outline}
    \tableofcontents[currentsection, hideothersubsections]
  \end{frame}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

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

\begin{frame}
\frametitle{Outline}
\tableofcontents%
[hideallsubsections]
\end{frame}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
%%%%%%%%%%
\section{Section 1}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
\subsection{Sub 1.1}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
\subsection{Sub 1.2}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
%%%%%%%%%%
\section{Section 2}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
\subsection{Sub 2.1}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
\subsection{Sub 2.2}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

\end{document}

I tried to add the following piece of code, but it didn't work.

\AtBeginSubsection[]
{
  \begin{frame}<beamer>
    \frametitle{Outline}
    \tableofcontents[currentsection, currentsubsection, hideothersubsections]
  \end{frame}
}

Any feedback will be most welcome.

2
  • Should the other subsection of the current section be completely hidden or only shaded? Commented Jan 5, 2023 at 10:54
  • Shaded, as for the other (inactive) section and subsections.
    – Kolmin
    Commented Jan 5, 2023 at 11:13

1 Answer 1

1

You have more fine control if you use subsectionstyle=<style for current subsection>/<style for other subsections in current section>/<style for subsections from other sections> instead of currentsubsection and similar options. The possible styles are show, shaded and hide.

\documentclass{beamer}
 
\usetheme{CambridgeUS}
\usepackage[english]{babel}

\AtBeginSubsection[]
{
  \begin{frame}<beamer>
    \frametitle{Outline}
    \tableofcontents[ sectionstyle=show/shaded,subsectionstyle=show/shaded/shaded]
  \end{frame}
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

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

\begin{frame}
\frametitle{Outline}
\tableofcontents[hideallsubsections]
\end{frame}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
%%%%%%%%%%
\section{Section 1}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
\subsection{Sub 1.1}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
\subsection{Sub 1.2}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
%%%%%%%%%%
\section{Section 2}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
\subsection{Sub 2.1}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

%%%%%%%%%%
\subsection{Sub 2.2}

\begin{frame}
\frametitle{Bla}
Bla
\end{frame}

\end{document}

enter image description here

10
  • Thanks a lot. However, this is not exactly what I was looking for (but very close). Indeed, when the section (alone) starts, I would like to have a TOC with the section and all its subsections visible. Once we move to specific subsections, I would like to get exactly what you suggested.
    – Kolmin
    Commented Jan 5, 2023 at 12:57
  • 1
    @Kolmin ... but don't you already have this in your code? I didn't repeat your \AtBeginSection[]{...} code because this question is about showing the toc at the start of subsections. Commented Jan 5, 2023 at 13:01
  • Supersorry. I overlooked the fact that that piece of code doesn't have to go. Yep, now everything works like a charm. Thanks a lot, much appreciated!
    – Kolmin
    Commented Jan 5, 2023 at 13:42
  • Actually, I just realized there is a problem, that was not originally mentioned. I have an option that is not in the original MW where, when I activate the section, only its subsections are showed. Can we have an answer that implements also this?
    – Kolmin
    Commented Jan 5, 2023 at 13:46
  • @Kolmin subsectionstyle=show/show/hide Commented Jan 5, 2023 at 13:47

You must log in to answer this question.

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