# Badly aligned two column Beamer ToC

I'm trying to make a nice two column table of contents in beamer. There are a lot of questions about it, but I can't see that anyone really answers my problem.

Using the multicol environment, splitting the ToC is easy. However, the ToC is internally badly aligned, even thought the number of entries are even. I've added the code

\makeatletter
\patchcmd{\beamer@sectionintoc}
{\vfill}
{\vskip1.5em}
{}
{}
\makeatother


The question Beamer: Vertical alignment of multi-column ToC addresses the problem, but the solution is manual (providing which sections of the ToC that should be printed in which column). I believe it probably should be some way to fill the space needed in the first column such that the top of the two columns are balanced, but I have no idea how. Any ideas?

MWE:

\documentclass[xcolor=dvipsnames]{beamer}

\usepackage[utf8]{inputenc}
\usepackage{multicol,etoolbox}

\usecolortheme[named=OliveGreen]{structure}
\usefonttheme[stillsansseriflarge]{serif}

\AtBeginSection[]
{
\begin{frame}{Innhold}{\hfill}
\begin{columns}
\column{.1\textwidth}
\column{.8\textwidth}
\begin{multicols}{2}
\centering
%subsectionstyle=show/show/hide
]
\end{multicols}
\column{.1\textwidth}
\end{columns}
\end{frame}
}

\makeatletter
\patchcmd{\beamer@sectionintoc}
{\vfill}
{\vskip1.5em}
{}
{}
\makeatother

\begin{document}

\begin{frame}
{Innhold}{}
\begin{columns}
\column{.1\textwidth}
\column{.8\textwidth}
\begin{multicols}{2}
\tableofcontents
\end{multicols}
\column{.1\textwidth}
\end{columns}
\end{frame}

\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}
\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}
\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}
\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}
\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}
\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}

\end{document}

• Why do you need columns and multicols at the same time? – Symbol 1 Aug 24 '15 at 9:02
• Just to squeeze the ToC – got the code from a friend :p – Holene Aug 24 '15 at 14:08

In beamerbasetoc.sty, there is the definition of \beamer@tableofcontents

\def\beamer@tableofcontents[#1]{%
\def\beamer@toc@cs{show}%
\def\beamer@toc@os{show}%
\def\beamer@toc@css{show}%
\def\beamer@toc@oss{show}%
\def\beamer@toc@ooss{show}%
\def\beamer@toc@csss{show}%
\def\beamer@toc@osss{show}%
\def\beamer@toc@oosss{show}%
\def\beamer@toc@ooosss{show}%
\beamer@showpartnumber=\c@part%
\beamer@pausesectionsfalse%
\beamer@pausesubsectionsfalse%
\def\beamer@tocsections{<*>}%
\setkeys{beamertoc}{firstsection=1}%
\setkeys{beamertoc}{#1}%
\vspace*{-.5em}{\makeatletter%
\pause[0]%
\@input{\jobname.toc}%
\vfill}%
}


Somehow the \vspace*{-.5em} at the beginning pushes down the TOC. So just remove it.

I know it is kind of surprising. Just try it and you will see the result.

Roughly speaking, multicols makes the first line of every column at least 1em tall, that is, it is of height 1em or higher. Therefore when you say \vspace*{-.5em}, the negative space itself becomes the first line. So you may image that the first line has height 1em and depth -.5em. It is indeed a positive space, and hence pushed the contents down.

P.S. Technically, \vspaces, the verticals spaces, are different from horizontal boxes and do not have heights and depths, they are spaces already.

MWE

\documentclass[xcolor=dvipsnames]{beamer}

\usepackage[utf8]{inputenc}
\usepackage{multicol,etoolbox}

\usecolortheme[named=OliveGreen]{structure}
\usefonttheme[stillsansseriflarge]{serif}

\AtBeginSection[]
{
\begin{frame}{Innhold}{\hfill}
\begin{columns}
\column{.1\textwidth}
\column{.8\textwidth}
\begin{multicols}{2}
\centering
%subsectionstyle=show/show/hide
]
\end{multicols}
\column{.1\textwidth}
\end{columns}
\end{frame}
}

\makeatletter
\def\beamer@tableofcontents[#1]{%
\def\beamer@toc@cs{show}%
\def\beamer@toc@os{show}%
\def\beamer@toc@css{show}%
\def\beamer@toc@oss{show}%
\def\beamer@toc@ooss{show}%
\def\beamer@toc@csss{show}%
\def\beamer@toc@osss{show}%
\def\beamer@toc@oosss{show}%
\def\beamer@toc@ooosss{show}%
\beamer@showpartnumber=\c@part%
\beamer@pausesectionsfalse%
\beamer@pausesubsectionsfalse%
\def\beamer@tocsections{<*>}%
\setkeys{beamertoc}{firstsection=1}%
\setkeys{beamertoc}{#1}%
%\vspace*{-.5em}
{\makeatletter%
\pause[0]%
\@input{\jobname.toc}%
\vfill}%
}
\makeatother

\begin{document}

\begin{frame}
{Innhold}{}
\begin{columns}
\column{.1\textwidth}
\column{.8\textwidth}
\begin{multicols}{2}
\tableofcontents
\end{multicols}
\column{.1\textwidth}
\end{columns}
\end{frame}

\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}
\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}
\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}
\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}
\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}
\section{This is a section}
\begin{frame}
{}
Some content
\end{frame}

\end{document}

• the negative vspace pushes the ToC down? – Holene Aug 24 '15 at 14:10
• @Holene see my edit – Symbol 1 Aug 24 '15 at 15:08
• I don't know why, but copying the code into my MWE, changing the vspace to 0 or removing the entire entry, and compiling doesn't change a thing for me... – Holene Aug 24 '15 at 16:31
• @Holene I added a MWE. If it does not work, then it is me who should say I do not know why :) – Symbol 1 Aug 24 '15 at 16:41
• Is this the kind of result you get? dropbox.com/s/4mop13b6zams7hu/… I have emphasised the alignment in Skim – Holene Aug 24 '15 at 17:03