3

This is a follow up question of Page numbers > 99 in the table of content are not aligned correctly (cleanthesis). The formatting problem has nothing to do with cleanthesis.sty.

The problem is that if I use the charter font, page numbers greater than 99 are not formatted correctly in the table of content.

\documentclass[draft=on]{scrbook}
\usepackage{blindtext}
\usepackage{charter}

\listfiles

\begin{document}
\tableofcontents
\section{Section 1}
\blindtext[100]
\section{Section 2}
\blindtext[500]
\section{Section 3}
\end{document}
4

Change the value for \@pnumwidth (the space reserved to typeset page numbers):

\documentclass[draft=on]{scrbook}
\usepackage{blindtext}
\usepackage{charter}

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

\begin{document}
\tableofcontents
\section{Section 1}
\blindtext[100]
\section{Section 2}
\blindtext[500]
\section{Section 3}
\end{document}

enter image description here

scrbook.cls has by default:

\newcommand*\@pnumwidth{1.55em}
  • Thx, you are the hero of my day!!! – user4811 Aug 11 '13 at 12:21
3

Put this in your preamble:

\usepackage{tocloft}

\newlength\mylen

\renewcommand\cftchappresnum{\chaptername~}
\settowidth\mylen{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylen}

Full code:

\documentclass[draft=on]{scrbook}
\usepackage{blindtext}
\usepackage{charter}

\usepackage{tocloft}

\newlength\mylen

\renewcommand\cftchappresnum{\chaptername~}
\settowidth\mylen{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylen}

\listfiles

\begin{document}
\tableofcontents
\section{Section 1}
\blindtext[100]
\section{Section 2}
\blindtext[500]
\section{Section 3}
\end{document}

enter image description here

  • Your solution doesn't seem to work with subfig.sty. The solution from Gonzalo works better. But anyway, thanks a lot for your time. I appreciate it!!! – user4811 Aug 11 '13 at 12:25
  • @user4811 You have to load subfig after tocloft. – user11232 Aug 11 '13 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.