5

With the following example, I get a different vertical distance between "Contents" and "1 bar 5" and "foo" and "Lorem". How do I get the first entry of the TOC to the same height as "Lorem ipsum", that is the base line should be the red rule in the image below:

enter image description here

\documentclass{book}
\begin{document}
\tableofcontents

\chapter*{foo}
Lorem ipsum

\chapter{bar}
Lorem ipsum 

\end{document}
5

The command \l@chapter in book.cls typesets the chapter entry in the table of contents. It adds 1.0 em vertically before the entry. So, to remove that space before the first entry, you could redefine that macro or add a negative vertical skip before you start the first chapter, such as

\addtocontents{toc}{\vskip -1.0em}
\tableofcontents
\chapter*{foo}

Actually, the macro contains also a glue of 1 pt. From book.cls:

\newcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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