Beamer – How to Create a Fancy Table of Contents

beamertable of contents

How can I create a fancy-looking table of contents for a Beamer presentation?

toc

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\begin{document}

\frame{
\tableofcontents
}

\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}

\end{document}

Best Answer

A possible overkilling solution with TikZ:

\documentclass[svgnames]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\pgfdeclarehorizontalshading{section shading}{2cm}{
color(0cm)=(LightSlateGrey);
color(2cm)=(gray!7);
color(3cm)=(LightSlateGrey!15)
}
\usepackage{tikz}
\tikzset{section number/.style={
    draw=none,
    rectangle,    
    left color=gray!40,
    right color=gray!20!black,
    minimum size=1.5em,
    text=white,
  },
  section/.style={
    draw=none,
    rectangle,    
    shading=section shading,
    minimum height=1.5em,
    minimum width=0.9\textwidth,
    text width=0.9\textwidth,
    text=black,
    align=left
  }
}

\makeatletter
\setbeamertemplate{section in toc}{
  \ifnum\the\beamer@tempcount<10 %check to pad with 0
    \tikz[baseline=-0.5ex]\node[section number]{\,0\inserttocsectionnumber};%
  \else
    \tikz[baseline=-0.5ex]\node[section number]{\,\inserttocsectionnumber};%
  \fi
  \,%
  \tikz[baseline=-0.5ex]\node[section]{\inserttocsection};
}
\makeatother

\begin{document}


\frame{
\tableofcontents
}

\section{A very long title for this section}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\section{Another long title}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\section{Foo bar}
\frame{}
\end{document}

The result:

enter image description here

Notes: I think it is possible to do in a more elegant way with beamercolorboxes. The section number is displayed a bit shifted on the right (as per the initial picture) after a check on the section number: this is done in order to place a 0 in front of the section number in case it is below 10.