5

I am having trouble formatting the TOC for a document. I have long chapter titles which wrap onto two lines of TOC text. The problem is that the second line of a single chapter title is aligned with the chapter number, but I need it to align with the beginning of the title text on the first line:

Bad alignment with long chapter titles

I am using a style file that floats around my school, and here is the \l@chapter definition:

\def\l@chapter#1#2{%
\pagebreak[3]
\vskip .75em plus 1pt \@tempdima 1.5em 
\begingroup
    \parindent \z@ \rightskip \@pnumwidth
    \parfillskip -\@pnumwidth
    \leavevmode {\MakeUppercase{#1}\mydotfill \hbox to\@pnumwidth{\hss #2}}
    \par
\endgroup
}

Any ideas for how to get the second line to align with the text on the first??

thanks!

  • Also, when adding a chapter, the title is added to the TOC with this: \addcontentsline{toc}{chapter} {\protect\numberline{\thechapter} \normalsize\MakeUppercase{#1}}% – Eric Apr 18 '14 at 22:49
  • Do you know that you can use a different title for TOC? Just make use of \chapter[short]{long}. – Sigur Apr 18 '14 at 23:10
  • I don't have that problem with my thesis class (which also had to have the all-caps chapter titles in the ToC). What's your base document class, so I can see if my method works on yours? – Mike Renfro Apr 18 '14 at 23:30
  • You could take a look at the titletoc package. It is automaticaly the case that multiline titles have all their lines aligned with the first one. – Bernard Apr 19 '14 at 2:34
3

Here is perhaps an easier way of achieving it:

enter image description here

\documentclass{report}

\makeatletter
\def\l@chapter#1#2{%
\pagebreak[3]
\vskip .75em plus 1pt \@tempdima 1.5em 
\begingroup
  \parindent \z@ \rightskip \@pnumwidth
  \parfillskip -\@pnumwidth
  \advance\leftskip\@tempdima
  \hskip -\leftskip
  \leavevmode \MakeUppercase{#1}\dotfill \hbox to\@pnumwidth{\hss #2}
  \par
\endgroup
}
\makeatother

\begin{document}

\tableofcontents

\chapter{This is a super long chapter heading that requires more than one line in the Table of Contents}

\end{document}

The adjustment of \leftskip is taken directly from the definition of \l@chapter in book.cls.

0

My wife came up with a solution! (similar to Sigur). I put a manual line break and \hspace* in the short title, and adjusted the hspace distance until it lined up. Not elegant, but effective!

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.