# Using scrbook, how to suppress page numbers for all but several chapters in TOC?

I want to publish a book, and our publishing center style guide suggests the following style rules for the table of contents:

1. Every book chapter and section must have its entry in TOC.
2. If a book chapter doesn't have any sections, then it must have its page number in TOC, preceded by dots,
3. If a book chapter has nested sections, then only its name without page number must be present in TOC.

So I would like to suppress page numbers for numbered chapters, and show them only for unnumbered chapters, such as Introduction and Conclusion.

The MWE is below:

\documentclass[paper=a4,
fontsize=14pt,
DIV=calc,
twoside=false,
numbers=endperiod,
chapterentrydots=true,
]{scrbook}

\begin{document}

\tableofcontents

\newpage
\newpage
\chapter{Chapter without page number}
\section{Section One}

\end{document}


Update

With KOMA version 3.20 (or newer) it is possible to define an own tocentry style for unnumbered chapters. So here is a new suggestion to suppress the page numbers of all numbered chapters and to insert a dotted line for the unnumbered chapter entries in TOC.

\documentclass[paper=a4,
fontsize=14pt,
DIV=calc,
twoside=false,
numbers=endperiod,
]{scrbook}[2016/05/10]% needs version 3.20 or newer

\RedeclareSectionCommand[
tocpagenumberbox=\blankbox
]{chapter}
\newcommand\blankbox[1]{}% do nothing

\DeclareTOCStyleEntry[
level=\chaptertocdepth,
indent=0pt,
numwidth=1.5em,
]{chapter}{unnumberedchapter}
\makeatletter
\def\toclevel@unnumberedchapter{\chaptertocdepth}% needed if hyperref is used
\makeatother

\usepackage{xpatch}
{\IfArgIsEmpty{#1}
}{}{\PatchFailed}

%\usepackage{hyperref}
\begin{document}
\tableofcontents
\chapter{Chapter}
\section{Section One}
\end{document}


With a KOMA-Script class you can use

\addchap{Introduction}


instead \chapter*{Introduction}\addcontentsline{toc}{chapter}{Introduction}.

Here is a suggestion to suppress page numbers of all numbered chapters in TOC:

\documentclass[paper=a4,
fontsize=14pt,
DIV=calc,
twoside=false,
numbers=endperiod,
]{scrbook}

\setkomafont{chapterentrypagenumber}{\nullfont}

\IfArgIsEmpty{#1}
{\protect\begingroup
\protect\setkomafont{chapterentrypagenumber}{}%
\protect\KOMAoptions{chapterentrydots}%
}%
}
}

\begin{document}
\tableofcontents

• Unfortunately, miktex complains about undefined control sequence: ! Undefined control sequence. \addchaptertocentry #1#2->\IfArgIsEmpty {#1} {\addtocontents {toc}{\protect... l.26 \addchap{Introduction} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx'), type I' and the correct spelling (e.g., I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. Otherwise your TOC looks just great, thank you. – Andrey Sobolev Dec 2 '15 at 7:43
• Maybe you have to update your MiKTeX packages. Current KOMA Script Version in both MiKTeX 2.9 and TeXLive 2015 ist 3.19a. But you can replace \IfArgIsEmpty{#1}{...}{...} by \ifstr{#1}{}{...}{...}. – esdd Dec 2 '15 at 8:32
• MikTex 2.9 Package Manager shows me 3.15 as the latest version available, so I had to update it manually. Meanwhile I got one more question: if I try to import color or xcolor package, everything breaks down. Maybe you know why? – Andrey Sobolev Dec 2 '15 at 9:13
• I found a workaround by removing everything connected with pdfcolorstack from .toc` file manually, but if there is a way to do this automatically, I'll be very grateful. – Andrey Sobolev Dec 2 '15 at 10:48