0

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:

enter image description here

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[osf]{newpxtext} \linespread{1.05}
\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}
\addtokomafont{chapterentry}{\normalfont\lsstyle\scshape}
\DeclareTOCStyleEntries[raggedpagenumber=true, linefill=\qquad, pagenumberbox=\mbox]{tocline}{chapter,section,subsection}


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

\end{document}
6
  • 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?? Commented Jun 9, 2020 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
    Commented Jun 9, 2020 at 12:50
  • 1
    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. Commented Jun 9, 2020 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
    Commented Jun 9, 2020 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. Commented Jun 9, 2020 at 13:41

1 Answer 1

1
+50

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[osf]{newpxtext} \linespread{1.05}
\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}
\addtokomafont{chapterentry}{\normalfont\lsstyle\scshape}
\DeclareTOCStyleEntries[raggedpagenumber=true, linefill=\qquad, pagenumberbox=\mbox]{tocline}{chapter, section, subsection}
\DeclareTOCStyleEntry[entrynumberformat=\scshape]{tocline}{section}


\begin{document}

\tableofcontents

\appendix

\chapter{Test}
\section{Test}

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .