3

My document has three "parts" (using the \part command), and chapters, and sections. When I generate my table of contents (\tableofcontents), all the chapters and lower have dots between the name of the chapter/section/etc. and the page number. However, the parts do not have dots.

How do I fix this?

Here is the code in my cls that pertains to the table of contents, please advise how to make it so that parts also have dots.

\renewcommand\contentsname{Table of Contents}

\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus 0.2em \@minus 0.2em
    \setlength\@tempdima{1.5em}
    \begingroup
      \leftskip \z@ \rightskip \@tocrmarg \parfillskip -\rightskip
      \parindent \z@
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak
      \leaders\hbox{$\m@th\mkern\@dotsep mu\hbox{.}\mkern\@dotsep mu$}
      \hfil \nobreak\hbox to\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
\let\thesis@tableofcontents=\tableofcontents
\def\tableofcontents{{\singlespacing\thesis@tableofcontents}}

The document class uiucthesis2009 is used and this class based on book:

\LoadClass{book}
4
  • Can you post a link to the whole class?
    – Alan Munn
    Mar 11, 2012 at 18:23
  • Please note that "fixing issues with dots in ToC" usually means "getting rid of the dots": their very presence is the main problem (at least from aesthetical and functional points of view).
    – mbork
    Mar 11, 2012 at 19:11
  • I agree with your general opinion mbork - but my university is requiring them for my dissertation....
    – JMH
    Mar 11, 2012 at 19:23
  • @alan-munn - here is a link to the CLS file - netfiles.uiuc.edu/jhailpe2/www/uiucthesis2009.cls
    – JMH
    Mar 11, 2012 at 19:26

1 Answer 1

6

You show the chapter code but not the part code, the dots come ffom this bit of \l@chapter

 \leaders\hbox{$\m@th\mkern\@dotsep mu\hbox{.}\mkern\@dotsep mu$}
  \hfil 

If you look in your class file (or if it inputs one of the standard classes) you will find \ definition of \l@part that just has \hfil (white space) rather than the leaders. eg \l@part in article has

       \large \bfseries #1\hfil \hb@xt@\@pnumwidth{\hss #2}}\par

putting the \leaders line between #1 (the chapter title) and the \hfil will make the hfill work by repeating the dots rather than just using space.

like so:

\documentclass{uiucthesis}

\makeatletter

\renewcommand*\l@part[2]{%
  \ifnum \c@tocdepth >-2\relax
    \addpenalty{-\@highpenalty}%
    \addvspace{2.25em \@plus\p@}%
    \setlength\@tempdima{3em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      {\leavevmode
       \large \bfseries #1%
      \leaders\hbox{$\m@th\mkern\@dotsep mu\hbox{.}\mkern\@dotsep mu$}%
       \hfil \hb@xt@\@pnumwidth{\hss #2}}\par
       \nobreak
         \global\@nobreaktrue
         \everypar{\global\@nobreakfalse\everypar{}}%
    \endgroup
  \fi}

\makeatother

\begin{document}


\tableofcontents

\part{the first}

\chapter{foo}

\section{hmmm}

aaa

\section{hmmm}

bbb

\end{document}
8
  • Hi @david-carlisle, my cls file has no \l@part in it. So what would i do to add it?
    – JMH
    Mar 11, 2012 at 19:44
  • If part appears in the table of contents l@part must be defined, does your class \input or RequoreClass report or article class for example. You can find out the definition by adding \show\l@part but the error format breaks lines so it is nicer to copy from the original definition. (or just copy l@part from article.cls if you are really stuck) Mar 11, 2012 at 19:57
  • @DavidCarlisle: The class was added in a comment above. The relevant part: \LoadClass{book} Mar 11, 2012 at 20:00
  • Ah I see you gave a link it has \LoadClass{book} so take the definition of l@part from latex/base/book.cls, amended to have dots as in my answer Mar 11, 2012 at 20:01
  • @DavidCarlisle: I edited the question ;-) Mar 11, 2012 at 20:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .