Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Want to control the vertical space between sections in the TOC.

1,170 views
Skip to first unread message

Hongyi Zhao

unread,
Feb 24, 2009, 4:22:31 AM2/24/09
to
Hi all,

Consider the following minimal example:

-----------------
\documentclass[10pt]{article}

\begin{document}

\tableofcontents

\section{A}

\section{B}

\end{document}
-----------------

I want to change the default vertical space between sections in the
TOC, i.e., the vertical space between

1 A

and

2 B

Which command should I use to do trick? Thanks in advance.

--
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.

Lars Madsen

unread,
Feb 24, 2009, 4:35:19 AM2/24/09
to Hongyi Zhao
Hongyi Zhao wrote:
> Hi all,
>
> Consider the following minimal example:
>
> -----------------
> \documentclass[10pt]{article}
>
> \begin{document}
>
> \tableofcontents
>
> \section{A}
>
> \section{B}
>
> \end{document}
> -----------------
>
> I want to change the default vertical space between sections in the
> TOC, i.e., the vertical space between
>
> 1 A
>
> and
>
> 2 B
>
> Which command should I use to do trick? Thanks in advance.
>

tocloft or the memoir class


--

/daleif (remove RTFSIGNATURE from email address)

LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html

Sébastien Vauban

unread,
Feb 24, 2009, 5:13:05 AM2/24/09
to
Hello Hongyi Zhao,

Hongyi Zhao wrote:
> I want to change the default vertical space between sections
> in the TOC, i.e., the vertical space between

> Which command should I use to do trick? Thanks in advance.

Try `titletoc'. For example:

--8<---------------cut here---------------start------------->8---
\usepackage[dotinlabels]{titletoc}

\titlecontents{section} [7mm]% [left]
{\addvspace{4mm}}% {above}
{\bf\contentslabel{7mm}}% {before with label}
{}% {before without label}
{\bf\titlerule*[2.7mm]{.}\contentspage}% {filler and page}
[\addvspace{0mm}]% [after]

\titlecontents{subsection} [17mm]
{}
{\contentslabel{10mm}}
{}
{\titlerule*[2.7mm]{.}\contentspage}

\titlecontents{subsubsection} [30mm]
{}
{\contentslabel{13mm}}
{}
{\titlerule*[2.7mm]{.}\contentspage}
--8<---------------cut here---------------end--------------->8---

Seb

--
Sébastien Vauban

Hongyi Zhao

unread,
Feb 24, 2009, 6:41:31 AM2/24/09
to
On Tue, 24 Feb 2009 11:13:05 +0100, Sébastien Vauban
<zthjws...@spammotel.com> wrote:

>Try `titletoc'. For example:
>
>--8<---------------cut here---------------start------------->8---
>\usepackage[dotinlabels]{titletoc}
>
>\titlecontents{section} [7mm]% [left]
> {\addvspace{4mm}}% {above}
> {\bf\contentslabel{7mm}}% {before with label}
> {}% {before without label}
> {\bf\titlerule*[2.7mm]{.}\contentspage}% {filler and page}
> [\addvspace{0mm}]% [after]
>
>\titlecontents{subsection} [17mm]
> {}
> {\contentslabel{10mm}}
> {}
> {\titlerule*[2.7mm]{.}\contentspage}
>
>\titlecontents{subsubsection} [30mm]
> {}
> {\contentslabel{13mm}}
> {}
> {\titlerule*[2.7mm]{.}\contentspage}
>--8<---------------cut here---------------end--------------->8---

When I use it with beamer, I meet the following errors:

! Undefined control sequence.
l.634 \@tempskipa\@pnumwidth

?

Regards,

Hongyi Zhao

unread,
Feb 24, 2009, 6:43:22 AM2/24/09
to
On Tue, 24 Feb 2009 10:35:19 +0100, Lars Madsen
<dal...@RTFSIGNATUREimf.au.dk> wrote:

>tocloft or the memoir class

I want to use it with beamer, any minimal example please?

Sébastien Vauban

unread,
Feb 24, 2009, 7:41:52 AM2/24/09
to
Hongyi,

I'm sorry. My limit is reached...

But I guess that if you provide a minimal, but complete, example
that leads to that error, others could help.

Seb

--
Sébastien Vauban

Enrico Gregorio

unread,
Feb 24, 2009, 8:28:19 AM2/24/09
to
Sébastien Vauban <zthjws...@spammotel.com> wrote:

Of course the packages tocloft and titletoc are useless with beamer,
which uses a completely different approach to the table of contents.

As far as I can see, the entries are automatically spread out to fill
the frame.

Ciao
Enricos

Holger Bruenner

unread,
Feb 24, 2009, 5:01:02 PM2/24/09
to
On 24 Feb., 14:28, Enrico Gregorio <grego...@math.unipd.it> wrote:
> As far as I can see, the entries are automatically spread out to fill
> the frame.

Agreed. Sometimes, I find beamer trying to play the smart kid,
'optimizing' more than the user wants to have optimized...
(More often, the automatisms work just fine, so I'd not complain about
it!)

Generally, entries in list-like structures are spread over the page
(=frame) to achieve an equally spaced slide. In the case of the TOC
this is definitely unwanted, if there are only 2-3 entries. A quick
hack (and nothing to be taken as a sound typographic solution) would
be to keep together the TOC as a single parbox:

\documentclass[10pt]{beamer}
\begin{document}
\frame{\parbox{\textwidth}{\tableofcontents}}


\section{A}
\section{B}
\end{document}


Of course, enclosing the TOC in other environments (which are treated
as unbreakable entities by beamer) would have similar effects.

HTH,

Holger

Nick

unread,
Feb 27, 2009, 6:33:56 AM2/27/09
to


Hi

I have succesfully implemented this command several times...
\makeatletter
\def\addspacetotoc{\@ifnextchar[%]
\addspacetotocdefine\addspacetotocpreset}
\def\addspacetotocdefine[#1]{\addtocontents{toc}{\vskip #1\p@\protect
\mbox{}\par}}
\def\addspacetotocpreset{\addtocontents{toc}{\vskip 10\p@\protect\mbox
{}\par}}
\makeatother

It's a simple space adder, but you can substitue whatever you want.

Hope it'll be of use!

/Nick

0 new messages