21

In beamer, I guess, the separation space between the items from tableofcontents is stretchable:

enter image description here

Can you set it to a fixed value? e.g. to equal the value used in the itemize environment.

Partial answer:

\begin{minipage}{\textwidth}
   \linespread{1.4}
   \tableofcontents
\end{minipage}

Could someone patch this command with etoolbox and make it happen whenever typing only \tableofcontents? Thanks!

Here is a MWE (with default theme):

\documentclass{beamer}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{lipsum}


\title{Whatever Title Works}
\author{Remus M. Prunescu$^1$}
\institute{\tiny$^{1}$ Automation and Control Group, Department of Electrical Engineering, Technical University of Denmark (DTU)}

\begin{document}
\frame{
    \maketitle
}


\frame{
    \frametitle{Outline}
    \begin{minipage}{\textwidth}
       \linespread{1.4}
       \tableofcontents
    \end{minipage}
}

\section{Introduction}
\frame{
    \frametitle{Random}
    \lipsum[1]
}

\section{Project Description}
\frame{
    \frametitle{Random}
    \lipsum[2]
}

\end{document}
remus
  • 3,093

3 Answers3

23

And here's the proper way to do it in beamer: the inner command \beamer@sectionintoc (defined in beamerbasetoc.sty) inserts \vfill after each section entry in the ToC; patch the command to suppress \vfill and use a vertical skip of \itemsep (the separation between items in a list) or any other length that suits your needs:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{etoolbox}
\usepackage{lipsum}

\makeatletter
\patchcmd{\beamer@sectionintoc}
  {\vfill}
  {\vskip\itemsep}
  {}
  {}
\makeatother  

\title{Whatever Title Works}
\author{Remus M. Prunescu$^1$}
\institute{\tiny$^{1}$ Automation and Control Group, Department of Electrical Engineering, Technical University of Denmark (DTU)}

\begin{document}

\frame{
\frametitle{Outline}
\tableofcontents
}

\section{Introduction}
\frame{
\frametitle{Random}
\lipsum[1]
}

\section{Project Description}
\frame{
\frametitle{Random}
\lipsum[2]
}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • 1
    Thanks! I also added \pretocmd{\beamer@subsectionintoc} {\vskip0.5\itemsep}{}{} for subsections (which, I guess, are not using \vfill inbetween). Is this the correct way to do it? And yes, I only need to skip 0.5\itemsep to get the impression that subsections are grouped with the section. – remus Apr 09 '14 at 06:46
  • @remus Yes, you're right; in the case of subsections no \vfill is added and your addition will give you some little extra spacing (you could have patched \beamer@subsection to add there the space to the ToC, but you're approach will give the desired extra spacing). – Gonzalo Medina Apr 09 '14 at 12:36
  • 3
    This works for the TOC at the beginning of the presentation, but it doesn't appear to have any effect on the TOC that is repeated at the beginning of sections with \AtBeginSection etc. Is there a way of making this consistent? – Guido Vanden Wyngaerd Mar 03 '19 at 07:59
4

Here is a way to patch \tableofcontents such that its contents are embedded inside a minipage:

\pretocmd{\tableofcontents}{\begin{minipage}{\textwidth}}{}{}
\apptocmd{\tableofcontents}{\end{minipage}}{}{}

The MWE then becomes:

\documentclass{beamer}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{etoolbox}

\title{Whatever Title Works}
\author{Remus M. Prunescu$^1$}
\institute{\tiny$^{1}$ Automation and Control Group, Department of Electrical Engineering, Technical University of Denmark (DTU)}

\pretocmd{\tableofcontents}{\begin{minipage}{\textwidth}}{}{}
\apptocmd{\tableofcontents}{\end{minipage}}{}{}

\begin{document}
\frame{
    \maketitle
}


\frame{
    \frametitle{Outline}
    \tableofcontents
}

\section{Introduction}
\frame{
    \frametitle{Random}
    \lipsum[1]
}

\section{Project Description}
\frame{
    \frametitle{Random}
    \lipsum[2]
}

\end{document}
remus
  • 3,093
3

You could use the following work-around for your first frame and then play with the second argument of \fontsize to adjust the space between the lines:

\frame{
  \frametitle{Outline}
  \bgroup
    \vskip1\baselineskip
    \fontsize{10}{18}\selectfont
    \tableofcontents
    \vskip0pt plus 1filll
  \egroup
}

I've taken your initial example, no additional packages are necessary.

Lupino
  • 2,772