9

I am writing my thesis and use the book class under PhDthesisPSnPDF.

I would like to remove the dots in table of contents only for a particular entry like "Appendix". All the entries for chapter and section in the table of contents have dots and page numbers, I need to get rid of page number and the dots for the appendix in the TOC. Is there way to do?

  • But the linked PDF does not show any dots for chapters. So what packages are you including that is causing these dots to appear for chapters? – Werner Sep 12 '12 at 19:21
14

A heading command like \section{A} writes a line into the .toc file that looks like this:

\contentsline {section}{\numberline {1.1}A}{2}

when this is read back in \contentsline{section} simply expands to \l@section and that is then the command that picks up the remaining arguments and produces the toc entry. Most often (but not always) this command is defined as a special instance of \@dottedcontentsline, e.g., in the book class you find:

\newcommand*\l@section{\@dottedtocline{1}{1.5em}{2.3em}}

So to get rid of the dots in some cases there are different approaches possible and the depend on how things are defined and which entries you have to change in reality.

Plan A

Assuming that your toc uses \@dottedtoclinethen to get rid of the dots we can redefine \@dotsep to have a very high number. Assuming further, that we only want to change the sections at the end of the toc and we do not need to have dots appearing later on again. Then the following in front of the appendix in the source document will do the trick:

\makeatletter
\addtocontents{toc}{\def\string\@dotsep{100}}
\makeatother

This will write \def\@dotsep{100} into the toc file and from that point on the dots are gone.

If you need them back at a later point issue

\makeatletter
\addtocontents{toc}{\def\string\@dotsep{4.5}}  % 4.5 might be a different value in your class
\makeatother

Plan B

Make the heading commands in the appendix area or whenever you want a different toc style not write \contentsline{section}but, say, \contentsline{appsection} and then define \l@appsection to format the toc entry according to the desired style.

For this one would need to look for the places in the heading commands that issue \addcontentsline and change that code.

Fairly elaborate but much more general.

  • Frank, thank your for your great answer. Plan A did the trick. The appendix chapter was at the very end of the TOC so need to turn it on again. I was looking a solution for so long :) – Nasuf SONMEZ Sep 12 '12 at 21:37

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.