# Modify format of chapter number in toc independent of chapter number in heading

I want to format the toc-chapter numbers indpendent of the chapter numbers in the text. The chapter number for the appendix should be in small caps. However, I've modified the \chapterformat in a \EuRoman font. Thus, using \renewcommand*{\thechapter}{\textsc{\alph{chapter}}} changes the appearance of the chapter heading in the text.

What the heading should look like:

What the toc should look like:

MWE:

\documentclass[10pt, oneside, numbers=noenddot, listof=totoc, toc=indentunnumbered]{scrbook}
\usepackage{anyfontsize}
\usepackage{newpxmath}
\usepackage{microtype}
\DeclareMathAlphabet\EuRoman{U}{eur}{m}{n}
\SetMathAlphabet\EuRoman{bold}{U}{eur}{b}{n}
\newcommand{\eurom}{\EuRoman}

\usepackage[left=32.5mm, right=25mm, top=25mm, bottom=20mm]{geometry}

\renewcommand*{\chapterformat}{\textls*[-30]{\Huge\fontfamily{pplx}\selectfont$\eurom\thechapter$}}
\setkomafont{chapter}{\huge\fontfamily{qpl}\selectfont\normalfont\lsstyle\scshape}

\begin{document}
\tableofcontents
\appendix
% \renewcommand*{\thechapter}{\textsc{\alph{chapter}}}
\chapter{test}
\section{test}

\end{document}

• I have no idea what you actually want. But you shouldn't add to \thechapter formatting instructions, and specially not instructions meant only for one location. Beside this: why on earth are you setting the chapter number in math mode?? – Ulrike Fischer Jun 9 at 12:06
• it is in math mode to achieve the font from from this question. The chapter numbering should be in this font and the toc should display small caps – fuj36840 Jun 9 at 12:50
• Well, complicated way to select a font. Simply \newcommand\eurom{\usefont{U}{eur}{b}{n}} (or m instead of the b if it shouldn't be bold) should work too. – Ulrike Fischer Jun 9 at 12:57
• but now the original problem still remains. switching to \renewcommand*{\thechapter}{\textsc{\alph{chapter}}} in order to use small caps in the toc changes the chapter number to a lower case letter, because small caps don't seem to exist in this font. How can I adjust the toc numbers font independent of the chapter numbers? – fuj36840 Jun 9 at 13:10
• As I said: \thechapter should not contain formatting command like \textsc. If you want to change the formatting in the toc use eg. entrynumberformat. – Ulrike Fischer Jun 9 at 13:41

I think this is what you want.

\documentclass[10pt, oneside, numbers=noenddot, listof=totoc, toc=indentunnumbered]{scrbook}

\usepackage{anyfontsize}
\usepackage{microtype}
\usepackage{etoolbox}
\usepackage{newpxmath}
\usepackage[left=32.5mm, right=25mm, top=25mm, bottom=20mm]{geometry}

\makeatletter
\patchcmd\appendix{\@Alph\c@chapter}{\@alph\c@chapter}{}{}
\renewcommand\chapterlinesformat[3]{%
\@hangfrom{\formatchapternumber{#2}}{#3}%
}
\newcommand*\formatchapternumber[1]{%
\usefont{U}{eur}{m}{n}\Huge
\MakeUppercase{#1}%
}
\renewcommand\sectionlinesformat[4]{%
\@hangfrom{\hskip #2\formatsectionnumber{#3}}{#4}%
}
\newcommand*\formatsectionnumber[1]{%
\scshape #1%
}
\makeatother
\setkomafont{chapter}{\huge\fontfamily{qpl}\selectfont\normalfont\lsstyle\scshape}
\DeclareTOCStyleEntry[entrynumberformat=\scshape]{tocline}{section}

\begin{document}

\tableofcontents

\appendix

\chapter{Test}
\section{Test}

\end{document}

• works perfect, except when I load the hyperref package. For some reason the chapter numbering appears as uppercase letters – fuj36840 Jun 11 at 15:46
• fixed it: for some reason the hyperref package needs to be loaded after the other code – fuj36840 Jun 12 at 11:49
• @Johannes hyperref should always be loaded last, with very few exceptions (cf. this question). – schtandard Jun 14 at 11:32