# Use oldstyle numbers for page numbers only, with KOMA-script

I'm using newtxtext/newpxtext together with scrbook and I'd like to use oldstyle numbers only for page numbers, but also for page numbers in the toc.

The former package offers the macro \useosf, which is not allowed in combination with

\addtokomafont{pagenumber}{\osf}


as it can only be used in the preamble. But \addtokomafont also ends up within the document when shipped out.

As a workaround I can use

\newcommand\oldstylenumbers{\fontencoding{TS1}\selectfont}


But it does not affect the page numbers in the toc. The only possible option I know of is:

\addtokomafont{chapterentrypagenumber}{\oldstylenumbers}


which is not available for sections and subsections etc.

How can I change all page numbers in the toc to oldstyle numbers?

I also read that changing \thepage is not recommended as it would break hyperref. That is not desirable.

## Full MWE

\documentclass{scrbook}

\usepackage{newtxtext}
\usepackage{siunitx}
\usepackage{blindtext}
\renewcommand{\sfdefault}{\rmdefault}

\newcommand\oldstylenumbers{\fontencoding{TS1}\selectfont}

\begin{document}
\tableofcontents
\chapter{Chapter}
\section{Section}
\subsection{Subection}
123456789 \num{123456789}
\blindmathpaper
\chapter{Chapter}
\subsection{Subection}
\blindmathpaper
\subsection{Subection}
\blindmathpaper
\chapter{Chapter}
\subsection{Subection}
\blindmathpaper
\chapter{Chapter}
\subsection{Subection}
\blindmathpaper
\chapter{Chapter}
\subsection{Subection}
\blindmathpaper
\subsection{Subection}
\blindmathpaper
\chapter{Chapter}
\subsection{Subection}
\blindmathpaper
\subsection{Subection}
\blindmathpaper
\subsection{Subection}
\blindmathpaper

\end{document}


You can change it with the tocpagenumberformat option. There is no need to define your own commands, \oldstylenums works fine.

\documentclass{scrbook}

\usepackage{newtxtext}
\usepackage{siunitx}
\usepackage{blindtext}
\renewcommand{\sfdefault}{\rmdefault}

\RedeclareSectionCommand[tocpagenumberformat=\oldstylenums]{section}
\RedeclareSectionCommand[tocpagenumberformat=\oldstylenums]{subsection}
\begin{document}
\tableofcontents
\chapter{Chapter}
\section{Section}
\subsection{Subection}
\oldstylenums{01234}
123456789 \num{123456789}
\blindmathpaper
\chapter{Chapter}
\subsection{Subsection}
\blindmathpaper
\subsection{Subsection}
\blindmathpaper
\chapter{Chapter}
\subsection{Subsection}
\blindmathpaper
\chapter{Chapter}
\subsection{Subsection}
\blindmathpaper
\chapter{Chapter}
\subsection{Subection}
\blindmathpaper
\subsection{Subection}
\blindmathpaper
\chapter{Chapter}
\subsection{Subection}
\blindmathpaper
\subsection{Subection}
\blindmathpaper
\subsection{Subection}
\blindmathpaper

\end{document}


• Thank you! As always my example was too minimal. \oldstylenums unfortunately breaks the numbering in case there are parts in the document with roman numbering. However, hidden in the source code of newpxtext and newtxtext I found the commands \osfstyle and \textosf which work like intended. – Robert Seifert Dec 26 '17 at 0:38
• Addendum: You can alternatively use \RedeclareSectionCommands[tocpagenumberformat=\oldstylenums]{section,subsection}. – Schweinebacke Dec 27 '17 at 15:05
• @Schweinebacke that does not work for me – Robert Seifert Dec 27 '17 at 16:35
• @thewaywewalk \RedeclareSectionCommands has been implemented in the same KOMA-Script version like \RedeclareSectionCommand. So it should work for you too. Did you get an error message? Which? – Schweinebacke Dec 27 '17 at 17:55
• @Schweinebacke I have overseen the s - it does work indeed! thanks! – Robert Seifert Dec 27 '17 at 20:04