I am using titletoc
to customise the ToC. Right now there are three things I cannot solve (I guess, due to the fact that page number is typeset in a fixed-width box):
- The
titlerule
doesn't fill till the page number. - If page number is too large, it exceeds into the right margin.
- If the title is too long, it bumps into the page number.
I have fixed the first issue with
\makeatletter
\renewcommand{\@pnumwidth}{0pt{}}
\makeatother
but the new problem appears
Full MWE:
\documentclass{book}
\usepackage[showframe]{geometry}
\usepackage{titletoc}
\makeatletter
\renewcommand{\@pnumwidth}{0pt{}}
\makeatother
\titlecontents{chapter}
[1cm]
{\vspace{1cm}\filright}
{\large\sffamily\bfseries\contentslabel[\thecontentslabel.]{1cm}}
{\hspace{-1cm}}
{\titlerule*[3pt]{.}\sffamily\bfseries\large\contentspage}
\begin{document}
\tableofcontents
\chapter{one}
Sample text
\cleardoublepage
\addtocounter{page}{1000}
\chapter{two}
\chapter{a long long long long long long long long long long long long long title}
\end{document}
\renewcommand{\p@numwidth}{0pt}
Really? Leaving no space for the page number box?