Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
    
Nice solution, thank you! –  Uwe Ziegenhagen Mar 30 '13 at 16:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.