There are three internal LATEX commands that are used in the typesetting the table of contents, lof, lot etc. They are (with their default values):
\@pnumwidth
= 1.55em
\@tocrmarg
= 2.55em
\@dotsep
= 4.5
The page number is typeset flushright in a box of width \@pnumwidth
, and the box is at the righthand margin. If the page number is too long to fit into the box it will stick out into the righthand margin. This is what is happening in your case.
The title text is indented from the righthand margin by
an amount given by \@tocrmarg
.
\@dotsep
gives the distance (in math units) between the dots in the leader.
Your problem is due to big numbers which can not be fitted into the box defined by the default value of \@pnumwidth
. Hence if we make the box bigger everything will be alright. We add the following in the preamble:
\makeatletter
\renewcommand{\@pnumwidth}{3em}
\renewcommand{\@tocrmarg}{4em}
\makeatother
Note that \@pnumwidth
should be always smaller than \@tocrmarg
.
For memoir these can be changed by
\renewcommand*{\cftdotsep}{1}
\setpnumwidth{3em}
\setrmarg{4em}
without any need for \makeatletter
construct.
Best Answer
The
\etocsettocstyle
command provides means to set some stuff before and after the ToC, i.e. the horizontal rules. Using it in a very primitive way, it will also prevent the page break etc.