3

in a scrrprt document I'm using proportional old style numbers throughout, but I want to use monospace lining numbers for the pages in the TOC.

I can use the chapterentrypagenumber font for the top level, but sectionentrypagenumber is only available for article (because it's the top level there). Which font is in use for the rest of the numbers?

Here's a simple test document — how do I change font for the black numbers?

\documentclass{scrreprt}
\usepackage{xcolor}
\setkomafont{chapterentrypagenumber}{\color{red}}
\setkomafont{disposition}{\color{teal}}
\begin{document}
{\color{blue}\tableofcontents}
\chapter{Chapter}
\section{Section}
\subsection{Subsection}
\end{document}

enter image description here

Also is there a simple debugging switch one could use for these things, to just put the name of the komafont in use into the document? I tried

\renewcommand{\usekomafont}[2]{(#1:#2)}

But there are clearly some font changes happening that I'm not catching: enter image description here

5

Use the tocstyle package from the KOMA bundle and the pagenumberhook:

\documentclass{scrreprt}
\usepackage{xcolor, tocstyle}
\setkomafont{chapterentrypagenumber}{\color{red}}
\setkomafont{disposition}{\color{teal}}
\settocstylefeature{pagenumberhook}{\sffamily{}}
\begin{document}
{\color{blue}\tableofcontents}
\chapter{Chapter}
\section{Section}
\subsection{Subsection}
\end{document}

I used \sffamily as font command, but maybe you'd like to have something else.


EDIT

It is a rainy day, I longed for something coloured and so I played around with this, just to find out which level of nonsense KOMAscript sustains:

\documentclass[x11names]{scrreprt}
\usepackage{xcolor, blindtext}
\usepackage{tocstyle}
\usetocstyle{KOMAlike}

\addtokomafont{chapterentrypagenumber}{\color{purple}}
\addtokomafont{chapter}{\color{purple}}

\addtokomafont{chapterentry}{\Large\color{purple}}
%\addtokomafont{disposition}{\color{Snow4}}
\settocstylefeature{entryhook}{\color{Wheat4!70!black}\bfseries}
 \settocstylefeature{pagenumberhook}{\rlap{\color{Wheat1}\hspace{-0.3em}\rule[-0.6ex]{0.6em}{2.5ex}\color{Wheat3}\rule[0.1ex]{0.6em}{2.5ex}}\bfseries\sffamily\color{teal}}

\begin{document}
 \tableofcontents
% \chapter{Chapter}
% \section{Section}
% \subsection{Subsection}

\blinddocument

\blinddocument

\end{document}

And you get such a cute TOC: contents-coloured

  • Yes that's what I ended up with, but I'd still like to know what KOMAscript does to the non-chapter page numbers – pascal Apr 29 '15 at 13:52
  • KOMA-script consists of tens of thousands (can you say that in English?) of lines of code. Even if I could explain it, you'd need to know a lot about TeX, LaTeX and KOMA-script. And if you knew this -- well, then you could find out yourself! – Keks Dose Apr 29 '15 at 13:55
  • 3
    @pascal: KOMA does nothing to the page numbers. By default is uses the standard \@dottedtocline to print the toc-lines, which in turn uses \normalfont \normalcolor to print the number. The fact that a hook has been added to one level doesn't mean that it exists for every level - KOMA isn't always really consequent (but it naturally can change in the future ...). – Ulrike Fischer Apr 29 '15 at 14:09
  • Ah, ok I expected it to use a komafont there instead of \normalfont directly, thanks! (the problem with KOMAscript is that it's not only massive and full of indirections, the internal parts are still documented mostly in german, but I'm not sure if that necessarily makes it harder to understand at that point) – pascal Apr 29 '15 at 16:13
  • Oh, this is so beautifully and ugly ;-) +1 – Johannes_B May 1 '15 at 15:53

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.