1

Beamer's frames with the t option are supposed:

  • to be vertically aligned at the top,
  • hence to display their first lines at the same vertical position.

Nevertheless, this is not the case for frames containing tables of contents, depending on these ToCs display subsections or not, as pointed out by the following MCE.

Do you see what's going on?

\documentclass{beamer}
\begin{document}
\section{Section 1}
\subsection{Subsection 1 of section 1}
\subsection{Subsection 2 of section 1}
\section{Section 2}
\subsection{Subsection 1 of section 2}
\subsection{Subsection 2 of section 2}
\begin{frame}[t]
  \tableofcontents
\end{frame}
\begin{frame}[t]
  \tableofcontents[hideallsubsections]
\end{frame}
\end{document}

enter image description here

2

While [t] configures the frame to be top-aligned, \tableofcontents adds some spacing on its own. It distributes the space between the sections in the normal case and sets 1.5em of space between sections for hideallsections. This is hardcoded in beamerbasetoc.sty in the \beamer@sectionintoc macro: The important part is

        \ifx\beamer@toc@ooss\beamer@hidetext
          \vskip1.5em
        \else
          \vfill
        \fi

You could add \vspace{0pt plus 1filll} at the bottom of the \tableofcontents frames to force them into top-alignment, but then the normal \tableofcontents start higher than the \tableofcontents[hideallsubsections] and there is no spacing between the sections for the first command, so it does not look great.

If you only care about aligning the first lines, you can add \vspace{1.5em plus -1fill} before \tableofcontents to align them: enter image description here

  • Interesting! Where are these precise dimensions coming from? Unfortunately, your last trick leads to a huge vertical space between the two sections displayed by \tableofcontents. – Denis Bitouzé Mar 19 '18 at 9:45
  • Investigating a bit, it turns out that replacing the \vfill by \vskip1.5em in \beamer@sectionintoc gives the expected result. I wonder if it should be the case when the the underlying frame has t option. – Denis Bitouzé Mar 19 '18 at 10:04
  • 1
    While this leads to reasonable spacing, it leaves the 1.5em vertical offset in contrast to "normal" [t] frames, so if you do this it would probably be reasonable to add a negative 1.5em space before the TOC to fix this. – Marcel Krüger Mar 19 '18 at 10:10
  • Indeed but, surprisingly enough, a negative space before the TOC of 1.5em is too much while of 1em is okay. – Denis Bitouzé Mar 19 '18 at 10:24
1

A combination of setting tocdepth manually and a top-aligned minipage seems to align the TOCs:

\documentclass{beamer}
\begin{document}
\section{Section 1}
\subsection{Subsection 1 of section 1}
\subsection{Subsection 2 of section 1}
\section{Section 2}
\subsection{Subsection 1 of section 2}
\subsection{Subsection 2 of section 2}

\begin{frame}[t]
  \begin{minipage}[t]{\textwidth}
  \tableofcontents
  \end{minipage}
\end{frame}
\setcounter{tocdepth}{1}
\begin{frame}[t]
  \begin{minipage}[t]{\textwidth}
  \tableofcontents
  \end{minipage}
\end{frame}
\end{document}

Result:

enter image description here

  • Indeed, but would be nice to keep the \tableofcontents' optional argument provided by beamer and to not have to manually enter minipages. – Denis Bitouzé Mar 19 '18 at 9: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.