1

I need to customize my Appendix but can not figure out how.

I need:

  1. Entry in my Main ToC at the beginning of the document generated with \tableofcontents
  2. Change the Name of Appendices displayed in the ToC to the German "Anhang"
  3. Insert the Appendix after my References
    • Titel Page with "Anhang"
    • ToC showing each Chapter/section of the Appendix and page number

What would be the best way to do this using the Appendix package?

Thanks!

EDIT: I need to edit the MWE so that the entries that currently show up in the Main ToC do not show any more, only the Entry: "Anhang". The first Page after the appendix Titel Page should be a separate ToC that shows the entries of the appendix and the page number.

Here is a MWE:

\documentclass[a4paper,12pt,twoside,ngerman]{scrartcl} 
\usepackage{setspace} 
\usepackage{lmodern} 
\usepackage[ngerman]{babel} 
\usepackage[toc,title,page]{appendix} % Anhang 

\renewcommand{\appendixpagename}{\appendixname}
\renewcommand{\appendixtocname}{\appendixname}

\begin{document} 
\tableofcontents %Inhaltsverzeichnis 
\newpage 
\section{Section}
Test 123
\newpage 
\subsection{SubSection 1} 
Test 123
\newpage 
\begin{appendices} 
\section{Test}

TEST 123

\section{Test 2}

TEST 123


\section{Test 3}

TEST 123


\end{appendices} 
\end{document}
2
  • Could you post a minimal compilable document? The translation, anyway, should be done automatically with the ngerman option of babel.
    – Bernard
    Commented Jul 15, 2017 at 15:04
  • @TeXnician: As I don't really speak german, I don't know the differences. Anyway, I've changed it.
    – Bernard
    Commented Jul 15, 2017 at 15:11

1 Answer 1

4

With a KOMA-Script class you can use the automatically loaded package tocbasic to define an additional ToC.

\documentclass[12pt,twoside,ngerman]{scrartcl} 
\usepackage{babel}

%%% see: https://komascript.de/comment/5578#comment-5578 (Markus Kohm)
\DeclareNewTOC[%
  owner=\jobname,
  listname={Inhalt des Anhangs},% Titel des Verzeichnisses
]{atoc}% Dateierweiterung (a=appendix, toc=table of contents)

\makeatletter
\newcommand*{\useappendixtoc}{%
  \renewcommand*{\ext@toc}{atoc}%
  \scr@ifundefinedorrelax{hypersetup}{}{% damit es auch ohne hyperref funktioniert
    \hypersetup{bookmarkstype=atoc}%
  }%
}
\ifundefinedorrelax{ext@toc}{%
  \newcommand*{\ext@toc}{toc}
  \renewcommand{\addtocentrydefault}[3]{%
    \expandafter\tocbasic@addxcontentsline\expandafter{\ext@toc}{#1}{#2}{#3}%
  }
}{}
\makeatother
%%%

\usepackage{xpatch}
\xapptocmd\appendix{%
  \cleardoublepage
  \vspace*{\fill}
  \addpart{\appendixname}
  \thispagestyle{empty}
  \vfill\vfill
  \clearpage
  \useappendixtoc
  \listofatocs
}{}{\PatchFailed}

\renewcommand\raggedpart{\centering}
\setkomafont{partentry}{\usekomafont{sectionentry}}

\usepackage{blindtext}
\begin{document} 
\tableofcontents 
\Blinddocument
\Blinddocument

\appendix
\blinddocument
\blinddocument
\end{document}

enter image description here

enter image description here

If you switch to scrreprt you can use:

\documentclass[12pt,twoside,ngerman]{scrreprt} 
\usepackage{babel}

%%% see: https://komascript.de/comment/5578#comment-5578 (Markus Kohm)
\DeclareNewTOC[%
  owner=\jobname,
  listname={Inhalt des Anhangs},% Titel des Verzeichnisses
]{atoc}% Dateierweiterung (a=appendix, toc=table of contents)

\makeatletter
\newcommand*{\useappendixtoc}{%
  \renewcommand*{\ext@toc}{atoc}%
  \scr@ifundefinedorrelax{hypersetup}{}{% damit es auch ohne hyperref funktioniert
    \hypersetup{bookmarkstype=atoc}%
  }%
}
\ifundefinedorrelax{ext@toc}{%
  \newcommand*{\ext@toc}{toc}
  \renewcommand{\addtocentrydefault}[3]{%
    \expandafter\tocbasic@addxcontentsline\expandafter{\ext@toc}{#1}{#2}{#3}%
  }
}{}
\makeatother
%%%

\usepackage{xpatch}
\xapptocmd\appendix{
  \cleardoublepage
  \addpart{\appendixname}
  \useappendixtoc
  \listofatocs
}{}{\PatchFailed}

\renewcommand\partpagestyle{empty}
\setkomafont{partentry}{\usekomafont{chapterentry}}

\usepackage{blindtext}
\begin{document} 
\tableofcontents 
\Blinddocument
\Blinddocument

\appendix
\blinddocument
\blinddocument
\end{document}

Dots between all TOC entries and their page numbers:

If you want to add dots between the chapter entries and their page numbers in all TOCs insert the following line in your preambel:

\RedeclareSectionCommands[toclinefill=\TOCLineLeaderFill]{chapter,part}

If you want to add these dots only in the appendix TOC use either

\xapptocmd\appendix{
  \cleardoublepage
  \addpart{\appendixname}
  \RedeclareSectionCommand[toclinefill=\TOCLineLeaderFill]{chapter}% <- added
  \useappendixtoc
  \listofatocs
}{}{\PatchFailed}

or

\xapptocmd\appendix{
  \cleardoublepage
  \addpart{\appendixname}
  \KOMAoptions{toc=chapterentrywithdots}% <- added
  \useappendixtoc
  \listofatocs
}{}{\PatchFailed}
5
  • Fantastic, this nearly does it for me. Only problem I see in my document is, that the Font size of "Anhang" in the first ToC is slightly bigger than the rest of the entries. In your MWE this does not to be a problem. I guess changing "\renewcommand\raggedpart{\centering} \setkomafont{partentry}{\usekomafont{sectionentry}}" could help, but I tried subsectionentry and instead of sectionentry but it would not do anything. Commented Jul 16, 2017 at 12:50
  • I figured that it has to do with the fact that I am using report class in my actual document and not the article class. Is there a possible fix for this? Commented Jul 16, 2017 at 13:05
  • Change \usekomafont{sectionentry} to \usekomafont{chapterentry}. But there are some additional changes needed. See the second example in my updated answer.
    – esdd
    Commented Jul 17, 2017 at 4:27
  • Great Stuff, Thank You! Just a quick follow up: Is there a way to have dots as a filler from entry name to page number in the appendix ToC? Commented Jul 17, 2017 at 6:27
  • I have added a suggestion for the dots at the end of my answer.
    – esdd
    Commented Jul 18, 2017 at 6:58

You must log in to answer this question.

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