[Tex/LaTex] Modification of appendix entries in ToC (KOMA-Script)

appendicesindentationkoma-scripttable of contents

Four questions concerning appendix entries in the ToC:

  1. As you can see in the attached picture, I want the page numbers for each appendix entry to be not bold, but normal font (like those of sections). Only the Appendix itself (introduced with a page with the word "Appendix" on it) should have a bold one because it is treated like a chapter.

  2. I would like to have these dots for each sub-appendix entry (Appendix 1, Appendix 2, …) (again like in the section entries).

  3. I'm not happy with the indentation you can see in the picture if there is more than one line for a sub-appendix entry. I'd like to arrange it like demonstrated in the attached picture.

  4. Is there a way to reduce the spacing between the sub-appendix entries? (analogue to the behaviour with sections, subsections, …)

enter image description here

\documentclass[%
    fontsize        =   12pt,
    BCOR            =   10mm,
    DIV             =   calc,
    chapterprefix   =   true,
    headings        =   big,
    toc             =   bibliography,
    toc             =   listof,
    numbers         =   noenddot]
    {scrreprt}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}                            
\usepackage[utf8]{inputenc}                     
\usepackage{etoolbox}
\providecommand*{\appendixmore}{}
\newcommand*{\SavedOriginaladdchaptertocentry}{}
\appto\appendixmore{%
\let\SavedOriginaladdchaptertocentry\addchaptertocentry
\renewcommand*{\addchaptertocentry}[2]{%
\ifstr{#1}{}{%
\SavedOriginaladdchaptertocentry{}{#2}%
}{%
\SavedOriginaladdchaptertocentry{}{\normalfont\small\appendixname~#1:\enskip#2}%
}%
}%
}
\usepackage[%
    bookmarks           =   true,
    bookmarksopen       =   false,
    bookmarksnumbered   =   true,
    pdfcenterwindow     =   true,
    pdfdisplaydoctitle  =   true,
    pdfencoding         =   auto,
    pdffitwindow            =   false,
    pdfstartview            =   FitV,
    draft               =   false]
    {hyperref}

\begin{document}                            

\pagenumbering{Roman}
\tableofcontents


\chapter{I am Chapter One}

\pagenumbering{arabic}                              

Test.

\section{Test}

\section{Test Test}

\chapter{I am Chapter Two}

\pagestyle{empty}
\clearpage

\phantomsection                                     
\vspace*{\fill}
\begin{center}
{\Huge\bfseries{Appendix}}
\end{center}
\vspace*{\fill}
\thispagestyle{empty}
\addcontentsline{toc}{chapter}{Appendix}

\appendix

\setkomafont{chapter}{\normalsize}

\renewcommand*{\thechapter}{\arabic{chapter}}

\chapter{\texorpdfstring{I am the first appendix with a long heading that takes more than just one line}{I am the first appendix with a long heading that takes more than just one line}}

\chapter{\texorpdfstring{I am the second appendix with a long heading that takes more than just one line}{I am the second appendix with a long heading that takes more than just one line}}

\end{document}

Best Answer

An alternative solution.

semeKomaTocAppendicToc

\documentclass[%
    fontsize      = 12pt,
    BCOR          = 10mm,
    DIV           = calc,
    chapterprefix = true,
    headings      = big,
    toc           = bibliography,
    toc           = listof,
    toc           = indentunnumbered,%JB Optionally indent unnumbered chapters
numbers         = noenddot
]
{scrreprt}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{hyperref}
\begin{document}

\pagenumbering{Roman}
\tableofcontents


\chapter{I am Chapter One}
\pagenumbering{arabic}

Test.

\section{Test}

\section{Test Test}

\chapter{I am Chapter Two}

\cleardoublepage
\appendix
\vspace*{\fill}
\begin{center}
    {\Huge\bfseries\sffamily Appendix}
    \addchaptertocentry{}{Appendix}
\end{center}
\vspace*{\fill}


\renewcommand{\thechapter}{\appendixname~\Alph{chapter}}
\KOMAoptions{chapterprefix=false}
\renewcommand{\chapterlinesformat}[3]{#2\chapterheadmidvskip#3}
\addtocontents{toc}{
\protect\setkomafont{chapterentry}{\protect\normalfont\protect\normalcolor}
\protect\KOMAoptions{chapterentrydots}
\RedeclareSectionCommand[
    tocnumwidth=6em
]{chapter}
}


\chapter{\texorpdfstring{I am the first appendix with a long heading that takes more than just one line}{I am the first appendix with a long heading that takes more than just one line}}

\chapter{\texorpdfstring{I am the second appendix with a long heading that takes more than just one line}{I am the second appendix with a long heading that takes more than just one line}}

\end{document}