In table of contents, long page numbers intrude on right margin despite plenty of available space

Some of the page numbers listed in my table of contents are long roman numerals. For some reason, these long page numbers get pushed into the right margin.

Here is a screenshot of the table of contents. Note that the "xviii" page number gets pushed into the right margin, creating a black "warning blot".

How can I fix this? Below is some minimal code that recreates this problem:

\documentclass[12pt,draft,letterpaper]{report}
\usepackage{tocloft}

\begin{document}

\pagenumbering{roman}

% PROBLEM: In the table of contents here, the abstract's page number is pushed
%          into the right margin.
\tableofcontents
\newpage .

Here are the acknowledgements.

% a bunch of blank pages, to place the abstract on page xviii
\newpage . \newpage . \newpage . \newpage . \newpage .
\newpage . \newpage . \newpage . \newpage . \newpage .
\newpage . \newpage . \newpage . \newpage . \newpage .

This is the abstract.

\end{document}

-
Try in the preamble \makeatletter \def\@pnumwidth{50pt}\makeatother –  Yiannis Lazarides Apr 27 '12 at 19:15

tocloft provides \cftsetpnumwidth{<len>} which sets the value of \@pnumwidth to <len>, so you could just execute

\cftsetpnumwidth{3em}% 3em width for page numbers


after loading tocloft (see 2.3 Typesetting the entries, p 8 of the tocloft documentation):

-

Increase the space reserved to typeset the page number; add to your preamble

\makeatletter
\renewcommand\@pnumwidth{1cm}
\makeatother


and instead of 1cm use a suitable length.

\documentclass[12pt,draft,letterpaper]{report}

\makeatletter
\renewcommand\@pnumwidth{1cm}
\makeatother

\begin{document}

\pagenumbering{roman}

\tableofcontents

\newpage

\newpage

\setcounter{page}{18}

\chapter*{Abstract}