1

I am trying to fix the overfull that Latex generates to take up the whole page. However, I am also dealing with a similar message for the ToC

enter image description here enter image description here

Now looking at the incriminated ToC I notice that the page numbers are slightly overflowing out of the margin. How can this problem be solved? I understand that the problem occurs because the page numbers are in bold type. I am currently working with the KOMAscript class.

A minimal working example

\documentclass[a4paper,11pt,twoside,draft]{scrbook}

\usepackage{lipsum}
\usepackage[
    top = 3cm, 
    bottom = 3cm, 
    right = 3cm, 
    left = 3cm, 
    headsep = 25pt, 
    bindingoffset = 5mm
]{geometry}

\begin{document}

\tableofcontents

\chapter{MyOne}
\lipsum[1-250]

\chapter{MyTwo}
\lipsum[1-250]

\chapter{Mythree}
\lipsum[1-250]\lipsum[1-250]

\chapter{MyFour}
\lipsum[1-250]

\chapter{MyFive}
\lipsum[1-250]

\end{document}

2
  • Without minimal working example I can only guess, but not show an answer. I guess, you have to increase the width of the box reserved for the page numbers (either of all entries or the chapter entries). See the tocbasic chapter in the KOMA-Script manual for more information.
    – cabohah
    Commented Oct 29, 2023 at 18:17
  • @cabohah Ok i edited the question and provide a MWE.
    – SimoPape
    Commented Oct 29, 2023 at 18:48

1 Answer 1

1

As already told in a comment, you have to increase the width of the box reserved for the page number. You can do this for the entry of one ToC level only, in your case the chapter entries, either using \DeclareTOCStyleEntry or using \RedeclareSectionCommand:

\documentclass[a4paper,11pt,twoside,draft]{scrbook}

\usepackage{lipsum}
\usepackage[
    top = 3cm, 
    bottom = 3cm, 
    right = 3cm, 
    left = 3cm, 
    headsep = 25pt, 
    bindingoffset = 5mm
]{geometry}

\DeclareTOCStyleEntry[pagenumberwidth=2em]{chapter}{chapter}
%\RedeclareSectionCommand[tocpagenumberwidth=2em]{chapter}

\begin{document}

\tableofcontents

\chapter{MyOne}
\lipsum[1-250]

\chapter{MyTwo}
\lipsum[1-250]

\chapter{Mythree}
\lipsum[1-250]\lipsum[1-250]

\chapter{MyFour}
\lipsum[1-250]

\chapter{MyFive}
\lipsum[1-250]

\end{document}

using \DeclareTOCStyleEntry

See section 15.3 and table 15.2 and figure 15.3 of the KOMA-Script manuals for more information about \DeclareTOCStyleEntry and the features of style tocline, and see section 21.8 for more information about \RedeclareSectionCommand and how to use it so configure not only the sectioning commands but also the corresponding ToC entries.

If you want to change several entries, you can either use \RedeclareSectionCommands (note the s at the end) instead of \RedeclareSectionCommad or \DeclareSectionTOCEntries instead of \DeclareSectionTOCEntry.

To change the default for all entries, you can just redefine \@pnumwidth:

\documentclass[a4paper,11pt,twoside,draft]{scrbook}

\usepackage{lipsum}
\usepackage[
    top = 3cm, 
    bottom = 3cm, 
    right = 3cm, 
    left = 3cm, 
    headsep = 25pt, 
    bindingoffset = 5mm
]{geometry}

\makeatletter
\renewcommand*{\@pnumwidth}{2em}
\makeatother

\begin{document}

\tableofcontents

\chapter{MyOne}
\lipsum[1-250]

\chapter{MyTwo}
\lipsum[1-250]

\chapter{Mythree}
\lipsum[1-250]\lipsum[1-250]

\chapter{MyFour}
\lipsum[1-250]

\chapter{MyFive}
\lipsum[1-250]

\end{document}

Note: Additionally it could be a good idea to also change the right indent of the entries. In this case see the ToC entry style feature rightindent or the default \@tocrmarg.

1
  • @Caborah Wonderful answer I couldn't ask for better. I had already read that section in KOMA documentation but I could not find the part to solve the problem. Again thank you very much
    – SimoPape
    Commented Oct 29, 2023 at 19:15

You must log in to answer this question.

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