0

MWE:

\documentclass{book}
\usepackage{tocloft}

\begin{document}
\tableofcontents

\newpage

\cftpagenumbersoff{chapter}

\addcontentsline{toc}{chapter}{CHAPTER 1}

\cftpagenumberson{chapter}

\addcontentsline{toc}{chapter}{CHAPTER 2}

Text.
\end{document}

which produces the TOC:

enter image description here

I thought, perhaps, that using \cftpagenumbersoff{chapter} before the Chapter 1 entry would turn the associated page number off; and then placing \cftpagenumberson{chapter} before the Chapter 2 entry would turn it back on. But that doesn't seem to be working.

How may I selectively turn page numbers off for chapters in the TOC?

1 Answer 1

2

You can add a line to the ToC with an empty page number using \contentsline.

a

\documentclass{book}

\begin{document}
    \tableofcontents    
    \newpage
    
    
    \chapter*{CHAPTER 1}        
    \addcontentsline{toc}{chapter}{CHAPTER 1}   
    
    \chapter*{CHAPTER 2}        
    \addtocontents{toc}{\protect\contentsline{chapter}{CHAPTER 2}{}{}\par}  % changed <<<<<<<<<<<
    
    \chapter*{CHAPTER 3}        
    \addcontentsline{toc}{chapter}{CHAPTER 3}
    
\end{document}
5
  • Thank you for this answer, it seems to work very nicely; however, when I incorporate your answer into my actual document, a dotfill appears. Do you have any idea what might be causing this?
    – DDS
    Commented Dec 12, 2022 at 15:14
  • Something in your document is modifying \l@chapter. The default for book class does not use \@dottedtocline. Commented Dec 12, 2022 at 15:36
  • @jean-marie Please update your question including the complete preamble you are using. Commented Dec 12, 2022 at 15:38
  • @JohnKormylo Thank you for your comment, I'll have to spend a little more time trying to figure out what is wrong.
    – DDS
    Commented Dec 12, 2022 at 15:54
  • Thank you for your helpful answer. The preamble is long and complicated. I must spend a little more time on figuring out what the problem may be.
    – DDS
    Commented Dec 12, 2022 at 15:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .