[Tex/LaTex] Add dots in table of contents for parts for LaTeX document

partstable of contents

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}

Best Answer

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}