I have created two custom macros for chapter and part command. When I am using following code:
\documentclass[final]{book}
\usepackage{lipsum}
\usepackage{tocloft}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\renewcommand{\cftchapfont}{\mdseries}
\renewcommand{\cftchappagefont}{\mdseries}
\long\def \mychapter#1{
\chapter*{#1}
\addcontentsline{toc}{chapter}{#1}
}
\long\def \mypart#1#2{
\part*{#1 \\* #2}
\addcontentsline{toc}{part}{#1\\ #2}
}
\begin{document}
\tableofcontents
\mypart{PART NUMBER 1}{Part Title}
\mychapter{Some chapter 1}
\lipsum[1-10]
\mychapter{Some chapter 2}
\lipsum[1-10]
\mychapter{Some chapter 3}
\lipsum[1-10]
\mypart{PART NUMBER 2}{Part Title}
\mychapter{Some chapter 4}
\lipsum[1-10]
\mychapter{Some chapter 5}
\lipsum[1-10]
\mychapter{Some chapter 6}
\lipsum[1-10]
\mychapter{Some chapter 7}
\lipsum[1-10]
\mypart{PART NUMBER 3}{Part Title}
\mychapter{Some chapter 8}
\lipsum[1-10]
\mychapter{Some chapter 9}
\lipsum[1-10]
\mychapter{Some chapter 10}
\lipsum[1-10]
\mychapter{Some chapter 11}
\lipsum[1-10]
\end{document}
it generates following Table of Contents:
Page numbers for \part
in this Table of Contents are not correct. Instead of pointing to real page where \part
text is printed, they point to page where first chapter within that part starts.
I have used pdflatex
two times to make sure page numbers will be correct, but they are not.
Questions:
- Why are page numbers for
\part
not correct in ToC? - How can I supress page numbers for
\part
altogether in ToC, but leave Table of Contents entry for\part
unchanged otherwise?
Best Answer
You're taking the wrong approach. If you don't want any element to be numbered, just tell LaTeX so.
LaTeX will take care of the rest.
If you want to suppress the page number for the parts, then do like this:
Thanks to Mico for suggesting
\cftpagenumbersoff
.