# Change font from Pagnumer in tableofcontents

I use in my document a font that is not a monospace. This has to follow that I have jumping numbers in my table of contents. How can I assign a different font to the page number? In the chapter \addtokomafont{chapterentrypagenumber}{\ttfamily} the rest of the elements section and subsequenten etc. don't work with it.

\documentclass[chapterprefix=false,parskip=half]{scrreprt}
\usepackage{mwe}
\usepackage{fontspec}
\usepackage[draft=false]{scrlayer-scrpage}
\setmainfont[
Ligatures=TeX,
Extension=.otf,
UprightFont=*-Regular,
BoldFont=*-Bold,
ItalicFont=*-Italic,
BoldItalicFont=*-BoldItalic,
]{Planer}
\setsansfont{Planer-Medium}

\begin{document}
\tableofcontents
\blinddocument
\end{document}


• Could you add a MWE ? – flav Feb 13 '19 at 15:53
• – Schweinebacke Feb 13 '19 at 17:06
• MWE added @flav ;) – Kai Feb 13 '19 at 17:33

KOMA-Script classes use package tocbasic to configure the ToC entries. So you can use \DeclareTOCStyleEntry/\DeclareTOCStyleEntries and their option pagenumberformat to change the format of the page number, e.g.:

\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{mwe}

\DeclareTOCStyleEntries[%
pagenumberformat=\texttt
]{section}{section,subsection}
\DeclareTOCStyleEntry[%
pagenumberformat=\textbftt
]{chapter}{chapter}
\newcommand*{\textbftt}[1]{\textbf{\texttt{#1}}}
\begin{document}
\tableofcontents
\blinddocument
\end{document}


KOMA-Script classes also provide to set ToC entry options using \RedeclareSectionCommand/\RedeclareSectionCommands by adding the prefix toc to the option name. So you can alternatively use, e.g.:

\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{mwe}

\RedeclareSectionCommands[%
tocpagenumberformat=\texttt
]{chapter,section,subsection}

\begin{document}
\tableofcontents
\blinddocument
\end{document}


However, the digits of the default LaTeX fonts are table digits, so even

\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{mwe}

\begin{document}
\tableofcontents
\Blinddocument
\Blinddocument
\end{document}


does not result in jumping page numbers. If you are using a font, where the digits have different widths, you should have look, whether it also provides table digits with same width for all digits. In this case you should be able to use the format option also to select the table digits.

• Jap, Danke das war es. Die Schrift hat leider keine Tabellenziffern. siehe mwe ;) – Kai Feb 13 '19 at 17:33
• @Kai I found several fonts named "Planer" in the net, but only one OTF font and that one is not free. So unfortunately, I cannot see anything with this MWE. However, if the answer is useful … – Schweinebacke Feb 14 '19 at 9:19