19

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".

Abstract's page number violates right margin

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 .

\section*{Acknowledgements}\addcontentsline{toc}{section}{Acknowledgements}

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 .

\chapter*{Abstract}\addcontentsline{toc}{section}{Abstract}

This is the abstract.

\end{document}
1
  • 1
    Try in the preamble \makeatletter \def\@pnumwidth{50pt}\makeatother
    – yannisl
    Apr 27, 2012 at 19:15

2 Answers 2

16

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):

enter image description here

20

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.

Your example code:

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

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

\begin{document}

\pagenumbering{roman}

\tableofcontents

\newpage

\section*{Acknowledgements}\addcontentsline{toc}{section}{Acknowledgements}

\newpage

\setcounter{page}{18}

\chapter*{Abstract}
\addcontentsline{toc}{section}{Abstract}

This is the abstract.

\end{document}

now produces

enter image description here

1
  • Best answer IMO as it does not need an external package. For me, {2em} works well for page numbers up until three digits.
    – jeannej
    Jul 6, 2020 at 17:08

You must log in to answer this question.

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