1

I use xelatex with KOMA script class scrreprt. Now I have to number my thesis appendices as sections A1.1, A1.2 and subsections A1.1.1, and so on. Chapter entries in the TOC including chapter APPENDICES should be set uppercase.

Therefore, I redefined the \thesection and \thesubsection. The hyperref option hypertexnames=false makes sure that the links are linked correctly. But now I want the TOC entries A1.1, ... aligned with the normal sections and subsections numbers like:

 1.1 Section
     1.1.1 Subsection
A1.1 Appendix Section
    A1.1.1 Appendix Subsection

Setting the main font Verdana with fontspec additionally leads to reduced spacing between A1.1 and the corresponding TOC entry:

Reduced spacing of section and subsection entries in TOC

This might by caused by not defining A as an appedix prefix.

Further, I tried to make the TOC chapter entries uppercase with:

\addtokomafont{chapterentry}{\MakeUppercase} 

But this produces error messages for the .toc file. Somehow this works fine for chapter titles in the text itself and also \nameref chapter is not uppercase as intended.

I hope anyone can help me with the appendix entry alignment and the uppercase chapter entry. Thank you in advance!

Here is my MWE:

% !TEX TS-program = xelatex

\documentclass[
a4paper,
10pt,
]{scrreprt}

\usepackage[no-math]{fontspec}
\PassOptionsToPackage{no-math}{fontspec}

\usepackage{footnotebackref}

\usepackage[showframe]{geometry}

\setmainfont[BoldFont={Verdanab.ttf},ItalicFont={Verdanai.ttf}]{Verdana.ttf} % <<< Reduces spacing in toc entries

\setlength{\parindent}{0pt}

% Chapter title
\setkomafont{chapter}{\Large\normalfont\bfseries\MakeUppercase}
\RedeclareSectionCommand[beforeskip=0pt]{chapter}

% TOC entry chapter level
\RedeclareSectionCommand[
toclinefill=\TOCLineLeaderFill
]{chapter}

\setkomafont{chapterentry}{\normalfont\bfseries}
%\addtokomafont{chapterentry}{\MakeUppercase} % <<< This does not work


% Section title
\setkomafont{section}{\large\normalfont\bfseries}

% Subsection/Subsubsection title
\setkomafont{subsection}{\normalsize\normalfont\bfseries}

\hypersetup{ 
    hypertexnames=false,
    colorlinks=true,
    citecolor=black,
    linkcolor=black,
    urlcolor=black,
    bookmarksnumbered,
    bookmarksdepth=2,
    bookmarksopenlevel=1,
    bookmarksopen=true,
} 

\begin{document}

\tableofcontents

\chapter{Main Body}

Reference to appedix \ref{app: First Appendix} or sub-appendix \ref{app: First Sub-Appendix}

\section{Section}

\subsection{Subsetion}

\chapter{Appendices}

\renewcommand{\thesection}{A\arabic{chapter}.\arabic{section}}
\renewcommand{\thesubsection}{A\arabic{chapter}.\arabic{section}.\arabic{subsection}}
\renewcommand{\thesubsubsection}{A\arabic{chapter}.\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
\setcounter{chapter}{1}
\setcounter{section}{0}
\setcounter{subsection}{0}
\setcounter{subsubsection}{0}

\section{First Appendix} \label{app: First Appendix}

\subsection{Fist Sub-Appendix} \label{app: First Sub-Appendix}

\end{document}
1
  • Normally I would suggest using the tocloft package but I have a feeling it doesn't work with the KOMA classes. Commented Sep 5, 2021 at 18:34

1 Answer 1

2

I would simply use the \appendix command, and set the uppercase through the tocentry command, adding a complex command with argument like \MakeUppercase to the font commands is bound to break in this place, as the argument contains the link commands.

\documentclass[
a4paper,
10pt,
]{scrreprt}

\usepackage[no-math]{fontspec}
\PassOptionsToPackage{no-math}{fontspec}

\usepackage{footnotebackref,etoolbox}

\usepackage[showframe]{geometry}

\setmainfont[BoldFont={Verdanab.ttf},ItalicFont={Verdanai.ttf}]{Verdana.ttf} % <<< Reduces spacing in toc entries

\setlength{\parindent}{0pt}

% Chapter title
\setkomafont{chapter}{\Large\normalfont\bfseries\MakeUppercase}
\RedeclareSectionCommand[beforeskip=0pt]{chapter}

% TOC entry chapter level
\RedeclareSectionCommand[
toclinefill=\TOCLineLeaderFill
]{chapter}

\setkomafont{chapterentry}{\normalfont\bfseries}

\renewcommand{\addchaptertocentry}[2]{%
\IfArgIsEmpty{#1}
 {\addcontentsline{toc}{chapter}{\protect\nonumberline\texorpdfstring{\protect\MakeUppercase{#2}}{#2}}}
 {\addcontentsline{toc}{chapter}{\protect\numberline{#1}\texorpdfstring{\protect\MakeUppercase{#2}}{#2}}}%
}%

% Section title
\setkomafont{section}{\large\normalfont\bfseries}

% Subsection/Subsubsection title
\setkomafont{subsection}{\normalsize\normalfont\bfseries}

\hypersetup{
    hypertexnames=false,
    colorlinks=true,
    citecolor=black,
    linkcolor=black,
    urlcolor=black,
    bookmarksnumbered,
    bookmarksdepth=2,
    bookmarksopenlevel=1,
    bookmarksopen=true,
}

\begin{document}

\tableofcontents

\chapter{Main Body}

Reference to appedix \ref{app: First Appendix} or sub-appendix \ref{app: First Sub-Appendix}

\section{Section}

\subsection{Subsetion}

\appendix
\chapter{Appendices}

\section{First Appendix} \label{app: First Appendix}

\subsection{Fist Sub-Appendix} \label{app: First Sub-Appendix}

\end{document}
1
  • Thank you very much! I may stick with the default appendix numbering A.1, A.1.1, ... . Further I did unnumbered chapters with \newcommand*{\unnumberedchapter}[1]{\chapter*{#1}\addcontentsline{toc}{chapter}{\protect\nonumberline\texorpdfstring{\protect\MakeUppercase{#1}}{#1}}} if anyone is interested in :) Commented Sep 6, 2021 at 19:14

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.