I use the following piece of code (titletoc package) to customize the "part entries" of my table of contents. Can you help me to push the page number to the right so that it is aligned with the other page numbers?
\titlecontents{part}[0pt]{
\protect\addvspace{15pt}%
}{}{\large\bfseries\partname{} }{$\;$\titlerule$\;$\large\bfseries\thecontentspage}[]
Complete working example
\documentclass{book}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{titletoc}
\titlecontents{part}[0pt]{
\protect\addvspace{15pt}%
}{}{\large\bfseries\partname{} }{$\;$\titlerule$\;$\large\bfseries\thecontentspage}[]
\begin{document}
\tableofcontents
\part{Part 1}
\chapter{Chapter 1}
\section{Section 1.1}
\section{Section 1.2}
\chapter{Chapter 2}
\section{Section 2.1}
\section{Section 2.2}
\part{Part 2}
\chapter{Chapter 1}
\section{Section 1.1}
\section{Section 1.2}
\chapter{Chapter 2}
\section{Section 2.1}
\section{Section 2.2}
\end{document}
Best Answer
Is that what you want? Your code didn't reset chapter numbers at each new part, so I used the
chngcntr
package.