0

While compiling the code:

\documentclass[draft]{book}
% ---------------------------------------------
\usepackage{titletoc}
\contentsmargin{0pt}
\titlecontents{chapter}[0pc]%
{\addvspace{2.7ex}\fontsize{14}{14}\selectfont}%
{\contentslabel[\thecontentslabel]{0pc}\hspace{1pc}}%
{}%
{\nolinebreak\hfill\thecontentspage}
% ---------------------------------------------
\begin{document}
\tableofcontents
\chapter{A chapter}
\end{document}

I get the warning:

Overfull \hbox (7.04991pt too wide) detected at line 1

What should I change to remove the warning?

2 Answers 2

2

With 0pc there is not enough room for the chapter number. For the MWE 7.1pt seems to be enough to accommodate the 1, in your real document, the required space may be larger.

\documentclass[draft]{book}
% ---------------------------------------------
\usepackage{titletoc}
\contentsmargin{0pt}
\titlecontents{chapter}[7.1pt]% <------------------------- change here
{\addvspace{2.7ex}\fontsize{14}{14}\selectfont}%
{\contentslabel[\thecontentslabel]{7.1pt}\hspace{1pc}}% <- and here
{}%
{\nolinebreak\hfill\thecontentspage}
% ---------------------------------------------
\begin{document}
\tableofcontents
\chapter{A chapter}
\end{document}
0

You can have a solution with \contentspush:

\documentclass[draft]{book}
% ---------------------------------------------
\usepackage[showframe]{geometry}
\usepackage{titletoc}
\usepackage{calc}
\contentsmargin{0pt}
\titlecontents{chapter}[0pt]%
{\addvspace{2.7ex}\fontsize{14}{14}\selectfont
}%
{\contentspush{\phantom{11}}\contentslabel[\hfill\thecontentslabel]{2em}\hspace{1pc}}%
{}%
{\nolinebreak\hfill\thecontentspage}
% ---------------------------------------------
\begin{document}

\tableofcontents
\chapter{A First Chapter}
\setcounter{chapter}9
\chapter{Another Chapter}

\end{document} 

enter image description here

You must log in to answer this question.

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