16

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}
  • 1
    I think you can include your MWE :) – percusse Apr 8 '14 at 10:08
  • @samcarter Thanks! The minipage approach works but I would like it embedded into \tableofcontents (maybe by patching the command using etoolbox). Do you know how to do that? – remus Apr 8 '14 at 12:18
  • sorry, I think this is beyond my ability. Some experts anywhere around here? – samcarter_is_at_topanswers.xyz Apr 8 '14 at 12:32
  • @percusse I added a MWE with default theme - looks different than the screenshot but the effect is still there. – remus Apr 8 '14 at 13:20
15

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

| improve this answer | |
  • 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 9 '14 at 6: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 9 '14 at 12:36
  • 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 3 '19 at 7: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}
| improve this answer | |
2

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.

| improve this answer | |

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.