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.

I have googled extensively and found no answer to my specific question. My problem is: I am creating lecture slides using the beamer class. My style file is University-specific. I have, in my first \section, more than 9 \subsections. When I create the \tableofcontents, this looks like here:

tableofcontents

Notice that the subsections with number >9 have a missing (or, at least, not visible) space between the number and the name of the subsection (e.g.: 1.10Vibromyogramm (VMG)).

How can I prevent this and make my TOC more legible?

EDIT1

After following some initial answers, \usepackage{tocloft} is not the solution since it does not work with the beamer class (others have noticed that, too - see List of Figures + Beamer?). Using tocloft causes pdflatex to fail with !LaTeX Error: \l@section undefined (it fails in the file tocloft.sty - and, as a previous poster said, lying to tocloft by defining the command as empty beforehand doesn't do any good either).

EDIT2

In reply to some comments by my fellow Latexers: If I only have, say, 3 \subsections, the spacing is exactly the same. Also, I do not think the reason is not only the style file; however, here is one line from the beamer font theme that is needed to understand the answer:

% Schriftart Helvetica
\usepackage[scaled]{helvet}
\renewcommand*{\familydefault}{\sfdefault} % Standard ist serifenlos

EDIT3

Thanks to Heiko's answer (see below), I have now found the solution to my problem. Thanks a bunch!

share|improve this question
1  
Welcome to TeX.sx! A tip: You can use backticks ` to mark your inline code as I did in my edit. –  Kurt Oct 19 '12 at 20:18
1  
It's quite hard to tell without knowing some details about the theme. –  egreg Oct 19 '12 at 21:37
    
With only 9 sections is the spacing between the subsection number and the subsection name the same or different than it is currently? –  Scott H. Oct 19 '12 at 21:47
    
As @egreg mentioned we need more infos about the theme. Whats the name of the theme? Whats the name of the uni? Inside the theme is the building of tocs realized. Knowings this allows to help you ... –  Kurt Oct 19 '12 at 21:56
    
I replied to your specific comments in the second edit above... I do not think it is the theme. In my google hunt, I have seen this problem quite some times, but w/o a satisfying solution. In a normal presentation, you would not have so many subsections, but in the specific case of a lecture... So maybe it is really the way that beamer creates the toc that is the problem. I just hate it. It does not look good. –  Bjoern Oct 19 '12 at 23:17

2 Answers 2

This solution creates a new option subsections numbered with max number of template subsection in toc that takes a section number as argument that is used for the maximal width of the number.

\documentclass{beamer}

% from beamerfontthemefau-4-3.sty
\usepackage[scaled]{helvet}
\renewcommand*{\familydefault}{\sfdefault}

% Define a new option `subsections numbered with max number'
% for template `subsection in toc'. The original code for
% `subsections numbered' can be found in beamerbaseauxtemplates.sty:
%
% \defbeamertemplate{subsection in toc}{subsections numbered}{%
%   \leavevmode
%   \leftskip=2em%
%   \rlap{%
%     \hskip-2em%
%     \inserttocsectionnumber.\inserttocsubsectionnumber
%   }%
%   \inserttocsubsection
%   \par
% }

\defbeamertemplate{subsection in toc}{subsections numbered with max number}[1]{%
  \leavevmode
  \settowidth{\leftskip}{#1~}%
  \rlap{%
    \hskip-\leftskip
    \inserttocsectionnumber.\inserttocsubsectionnumber~%
  }%
  \inserttocsubsection
  \par
}

\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered with max number]{1.10}

\begin{document}
\begin{frame}
\tableofcontents
\end{frame}
\begin{frame}
\section{Foo}
\subsection{Test}
\addtocounter{subsection}{8}
\subsection{Ten}
\end{frame}
\end{document}

Result

share|improve this answer
    
Heiko, your solution works perfectly. Thank you for your effort. I can not upvote, but I hope others will do. –  Bjoern Oct 20 '12 at 9:42

In beamerbasetoc.sty there is \def\subsectionintoc{} which appears to be responsible for setting subsections in the toc. I haven't used beamer, so I don't know if there is a good reason not to do the following, or whether it will work for you, but try including the following in your preamble:

\makeatletter

\def\subsectionintoc{}
\long\def\beamer@subsectionintoc#1#2#3#4#5#6{%
  \ifnum\c@tocdepth>1%
  \ifnum#5=\beamer@showpartnumber%
  {
    \beamer@saveanother%
    \gdef\beamer@todo{}%
    \beamer@slideinframe=#1\relax%
    \expandafter\only\beamer@tocsections{\gdef\beamer@todo{%
      \ifbeamer@pausesubsections\pause\fi%
      \beamer@tempcount=#6%
      \advance\beamer@tempcount by\beamer@sectionadjust%
      \edef\inserttocsectionnumber{\the\beamer@tempcount}%
      \def\inserttocsubsectionnumber{#2}%
      %
      % the following line originally read
      % \def\inserttocsubsection{\hyperlink{Navigation#4}{#3}}%
      % you can add a skip before printing the subsection name
      %
      \def\inserttocsubsection{\hyperlink{Navigation#4}{\hskip 5pt #3}}% 
      \beamer@tocifnothide{\ifnum\c@section=#1\beamer@toc@oss\else\beamer@toc@ooss\fi}%
      {%
        \def\beamer@breakhere{\\}%
        \beamer@tocact{\ifnum\c@section=#1\ifnum\c@subsection=#2\beamer@toc@css\else\beamer@toc@oss\fi\else\beamer@toc@ooss\fi}
        {subsection in toc}%
      }%
    }}%
    \beamer@restoreanother%
  }
  \beamer@todo%
  \fi\fi%
}

\makeatother

Alternatively, you might try to add the skip manually via.

\subsection{\unexpanded{\hskip 5pt}title}

or,

\subsection{\hskip 5pt title}

Both of which seem to work with what I have as a document.

share|improve this answer

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.