0

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}


\addtokomafont{chapterentrypagenumber}{\ttfamily}


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

enter image description here

3
2

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.

2
  • 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

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.