# Revert classfile changes without changing the class?

I am trying to add dots between the sections and the pages in my table of contents without using the package tocloft, since it moved my title from its original position. Right now it looks like this:

I have found that if I comment the following line from my .cls file, I get the desired output.

\let\@dottedtocline\@plaintocline


Here's what the desired ouytput looks like:

I would like to leave the .cls file untouched, as I understand it is best practice.

So how can I suppress the effect of that line from my .tex file, instead of modifying the class?

Here is the \@plaintocline command definition:

\def\@plaintocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent #2\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima #3\relax
{#4}\nobreak
\leaders\hbox{$\m@th \mkern \@dotsep mu\hbox{}\mkern \@dotsep mu$}\hfill
\nobreak
\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
\par}%
\fi}

• If you use \usepackage[titles]{tocloft} then your titles are spared. – user11232 Oct 23 '15 at 15:10
• You can use a \renewcommand{\@dottedtocline}{} with the correct number of arguments, being gobbled. Unless \edef is used, the \@dottedtocline is used when the outer macro is in action, not already on definition, so the redefined command comes into effect. – user31729 Oct 23 '15 at 15:10
• @gpedrosa: This depends on the class you are using. I don't know a class which has \@plaintocline so I don't know what you want to achieve! – user31729 Oct 23 '15 at 15:19
• Add thi9s to your preamble: \usepackage{etoolbox} \makeatletter \patchcmd{\@plaintocline}{\hbox{}}{\hbox{.}}{}{} \let\@dottedtocline\@plaintocline \makeatother – Gonzalo Medina Oct 23 '15 at 16:15
• @ChristianHupfer No; the definition of \@plaintocline is not the same as the kernel's \@dottedtocline; a dot is missing (see my comment above). – Gonzalo Medina Oct 23 '15 at 16:16

\makeatletter
\def\@dottedtocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent #2\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima #3\relax
{#4}\nobreak
\leaders\hbox{$\m@th \mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfill
\nobreak
\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
\par}%
\fi}
\makeatother


to the preamble should work. This should redefine \@dottedtocline the way it was before the \let you mention, i.e. the lay the LaTeX core latex.ltx defines it. If you tell me what class you use, I might find an option that switches off that \let. Or maybe you can try reading the documentation for it…

1. As you said, the manual mentions no option to reverse the change, saying instead:

A UFPEThesis não oferece nada em particular para a produção da bibliografia ou dos índices. Esse material deve ser criado da maneira usual discutida, por exemplo, em [1].

Or:

UFPEThesis offers nothing in particular for the production of the bibliography or of the indices. This material must be created in the usual manner discussed, for example, in [1].

2. As you notice, the only difference between the two tocline commands is the \hbox{.}, which is \hbox{} in the \@plaintocline macro. That is precisely what makes the dots. Basically (but I might be oversimplifying or getting things plain wrong), \leaders takes its argument and repeats it enough times to fill a line, so if it has nothing it puts nothing (\@plain), if it has a dot it puts a dot (\@dotted). You can have fun changing the contents of that \hbox and seeing strange things like:

1. Capitulo segundo * * * * * * * * * * * * * * * <pagenumber>

or:

1. Capitulo segundo foo foo foo foo foo foo foo foo foo <pagenumber>

if you like :).

A few more details about the command:

• First it checks if the number given as #1 is greater than \c@tocdepth, so if subsubsections are not supposed to be in the toc and you start one it won't create a line. If it is not greater, then it goes into the \else branch;
• There, it finds instructions to add vertical space, precisely a stretchable space in order to have some margin of stretchability to be able to avoid collapsing a page into the top section when the page is broken;
• Then it opens a group;
• Then we have some bookkeeping, more precisely some parameter changes;
• After that bookkeeping, which goes on till \null and includes \leavevmode to start a line, we have a \nobreak forbidding a linebreak (we are at the start of the line after all), then we have a negative horizontal space (I wonder why negative), then #4 is printed, which should be the chapter title or similar;
• After another \nobreak, we have the \leaders command, which contains \m@th, which is a spacing command I don't really know too much about, then a math space \mkern, the \hbox, and another \mkern; so the contents of the \hbox will be repeated surrounded by space; naturally, removing \mkern will reduce (or eliminate if you remove both \mkerns) the spacing around the dots/whatever is in the \hbox;
• The \hfill strikes me as out of place, but I probably do not know how \leaders works; anyway after this a break is forbidden, and a box of the width of a \@pnumwidth (a parameter containing a width suitable for page numbers, I should think) is created and placed there, which contains precisely the page number;
• \par, so new line, then close the group, then close the \else branch and the whole conditional with the \fi, and we are done.
• Interesting! The only difference I spot is the . in \hbox{.}. The way I see is you can't just comment that line from the tex file, you have to redefine the whole command (in my case the desired output was the default, found in the latex.ltx). Btw it works and not additional packages have to be loaded, thanks! – gpedrosa Oct 23 '15 at 17:10
• @gpedrosa perhaps your class provides an option to revert to the default. I cannot know for sure without knowing what class it is. – MickG Oct 23 '15 at 17:13
• The class I'm using is not on CTAN it is called ufpe thesis and I believe the manual is not in english, but I assure I've read the manual and did not find an option to do so – gpedrosa Oct 23 '15 at 17:32
• Uh-huh, probably wouldn't have tried then. Eu não falo Portugues :). Though Italian could have helped there :). – MickG Oct 23 '15 at 20:51
• Indeed @gpedrosa. But for some reason I expected it would help me less than it did :). You're welcome. – MickG Oct 25 '15 at 19:09