# Adjusting vertical space between TOC entries using Beamer

I have a rather lengthy table of contents for a presentation. Beamer is not compressing the vertical space between TOC entries, but instead running the last item off the bottom of the output! Is there a way to control this spacing?

I have tried

\begin{spacing}{0.9}
\tableofcontents
\end{spacing}


with the setspace package, but I don't think this is compatible with Beamer.

-

I don't know why it works, but if you put your \tableofcontents inside a minipage environment, the space between lines is reduced:

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

-
You may wish to use a minipage width that is a little more relative (as opposed to absolute), like \textwidth. –  Werner Feb 9 '12 at 5:58

In the beamer manual, look at the frame options shrink and squeeze.

The explanation for shrink is somewhat long, so I am not going to paste it here, but basically, it shrinks the text on a frame so it will actually fit to the frame. The squeeze option causes all vertical spaces in the text to be squeezed together as much as possible. Currently, this just causes the vertical space in enumerations or itemizations to be reduced to zero.

I am not sure it will work with TOC, but you can try it.

-
I guess this does not work with the TOC, because I am seeing no effect. Too bad; this would have been perfect. –  Kristen Apr 10 '11 at 0:54

Before writing this answer I've tested beamer and could insert 18 sections (without subsections) into a frame with default theme. So I'm not sure if last beamer version is already shrinking table of contents. In any case, some years ago I solved this problem changing tableofcontents definitions. What I did was extract next lines from beamer/base/beamerbasetoc.sty

\def\sectionintoc{}
\def\beamer@sectionintoc#1#2#3#4#5{%
\ifnum\c@tocdepth>0%
\ifnum#4=\beamer@showpartnumber%
{
\beamer@saveanother%
\gdef\beamer@todo{}%
\beamer@slideinframe=#1\relax%
\expandafter\only\beamer@tocsections{\gdef\beamer@todo{%
\beamer@tempcount=#5\relax%
\edef\inserttocsectionnumber{\the\beamer@tempcount}%
\beamer@tocifnothide{\ifnum\c@section=#1\beamer@toc@cs\else\beamer@toc@os\fi}%
{
\ifbeamer@pausesections\pause\fi%
\ifx\beamer@toc@ooss\beamer@hidetext
\vskip1.5em
\else
\vfill
\fi
{%
\hbox{\vbox{%
\def\beamer@breakhere{\\}%
\beamer@tocact{\ifnum\c@section=#1\beamer@toc@cs\else\beamer@toc@os\fi}    {section in toc}}}%
\par%
}%
}%
}
}%
\beamer@restoreanother%
}
\beamer@todo%
\fi\fi%
}


and paste into my main presentation file \begin{document} (don't forget \makeatletter and \makeatother) and change \vskip1.5em with \vskip0.5em. That's all.

-
I'm sorry, but I'm not anywhere near an expert. I don't know much about \makeatletter and \makeatother, except that I see them used in definitions. Can you explain? –  Kristen Apr 10 '11 at 1:09
@Kristen: @ is an special character in a tex file but a regular letter in sty or cls files. So when you insert some code from a class or style file into a tex file you must use \makeatletter before the code and \makeatother after it. Otherway you will hava errors. A better answer can be found in TeX FAQ: tex.ac.uk/cgi-bin/texfaq2html?label=atsigns. –  Ignasi Apr 10 '11 at 19:01

In Beamer version 3.10, tableofcontents is not correctly adjusted when using hideothersubsections. Also, squeeze does not work in tableofcontents. Shrink works, but makes small font sizes and too big spaces between them.

The best solution I have found is to define the size in the corresponding template, and specify a smaller size before the \tableofcontents:

\defbeamertemplate*{section in toc}{my theme}
{\leavevmode\leftskip=0.5em\large{\usebeamercolor[fg]{titlelike}\inserttocsectionnumber.} \inserttocsection\par}

\defbeamertemplate*{subsection in toc}{my theme}
{\leavevmode\leftskip=2em\normalsize{\usebeamercolor[fg]{titlelike}\inserttocsectionnumber.\inserttocsubsectionnumber.} \inserttocsubsection\par}

\defbeamertemplate*{subsubsection in toc}{my theme}
{\leavevmode\leftskip=3.5em\normalsize\usebeamerfont{subsection in toc}\usebeamerfont{subsubsection in toc}\inserttocsubsubsection\par}

\begin{frame}{Outline}
\scriptsize
\tableofcontents[currentsection,hideothersubsections]
\end{frame}

-

Based on minipage answer, you can try:

\renewcommand{\contentsname}{Outline}
\begin{frame}%[c]
\frametitle{\contentsname}
\begin{minipage}[t][4cm][t]{\textwidth}
\tableofcontents%[pausesections]
\end{minipage}
\end{frame}

-