4

I've used this code

\addtocontents{toc}{\cftpagenumbersoff{chapter}}

to remove the dots and page numbers after the entries in my ToC for all chapters. Is there a way to do this just for an arbitrary chapter?

The following is essentially the code I have.

\documentclass[twoside,openright, titlepage,numbers=noenddot, headinclude, %openany openright oneside twoside
                footinclude=true,cleardoublepage=empty, abstractoff, 
                BCOR=5mm,paper=a4,fontsize=11pt,%11pt,a4paper,
                ngerman,american
                ]{scrreprt}

\usepackage{tocloft}

\addtocontents{toc}{\cftpagenumbersoff{chapter}} 

\begin{document}

\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} 
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} 
\tableofcontents

\chapter{Test Chapter One}

\index{arte}
\section{Section One One}
\section{Section One Two}
\chapter{Test Chapter Two}
\section{Section Two One}
\section{Section Two Two}

\end{document}

The result is this

enter image description here

What I want is, for instance, only Test Chapter Two with dots after the title.

In particular is there a way to make the dots appear when the chapter has no sections?

  • Why exactly do you want this? You'd have to add it inside the .toc file it self in order to remove it, and then once more to add it again afterwards. Wouldn't it look odd with a varying design? – daleif Jan 9 '15 at 16:29
  • In the work I've done almost every Chapter is immediately followed by a section: the page of the section and of the chapter are the same. So when a chapter has no sections I would like to have at least a page number on the right (also without dots). So you say that is the only way to achieve this? – W4cc0 Jan 9 '15 at 16:39
5

Just put the toggles \addtocontents{toc}{\cftpagenumbersoff{chapter}} and \addtocontents{toc}{\cftpagenumberson{chapter}} when and where you need it.

\documentclass[twoside,openright, titlepage,numbers=noenddot, headinclude, %openany openright oneside twoside
                footinclude=true,cleardoublepage=empty, abstractoff, 
                BCOR=5mm,paper=a4,fontsize=11pt,%11pt,a4paper,
                ngerman,american
                ]{scrreprt}

\usepackage{tocloft}


\begin{document}

\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} 
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} 
\tableofcontents

\chapter{Test Chapter One}

\index{arte}
\section{Section One One}
\section{Section One Two}

\addtocontents{toc}{\cftpagenumbersoff{chapter}} 
\chapter{Test Chapter Two}
\section{Section Two One}
\section{Section Two Two}

\addtocontents{toc}{\cftpagenumberson{chapter}} 
\chapter{Test Chapter Three}
\section{Section Three One}
\section{Section Three Two}

\end{document}

enter image description here


And if for some reason you wanted the page number, but not the dots, for a single entry, try this:

\documentclass[twoside,openright, titlepage,numbers=noenddot, headinclude, %openany openright oneside twoside
                footinclude=true,cleardoublepage=empty, abstractoff, 
                BCOR=5mm,paper=a4,fontsize=11pt,%11pt,a4paper,
                ngerman,american
                ]{scrreprt}

\usepackage{tocloft}


\begin{document}

\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} 
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} 
\tableofcontents

\chapter{Test Chapter One}

\index{arte}
\section{Section One One}
\section{Section One Two}

\addtocontents{toc}{\def\protect\cftdotsep{10000}} 
\chapter{Test Chapter Two}
\addtocontents{toc}{\def\protect\cftdotsep{4.5}} 
\section{Section Two One}
\section{Section Two Two}

\chapter{Test Chapter Three}
\section{Section Three One}
\section{Section Three Two}

\end{document}

enter image description here

  • That's perfect! Thanks you so much! :-D – W4cc0 Jan 9 '15 at 17:55

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.