0

I found the following MWE from karlkoeller: Appendix in scrreprt - Separate table of appendices but mentioned in original TOC

This is nearly perfect for my use only one thing needs to be changed. Instead of

A. Chapter Name

I need:

Anhang 1: Chapter Name

Using

\renewcommand{\thechapter}{Anhang~\arabic{chapter}}

will not work, as it messes with the spacing in the ToC for the Appendix. Also FYI I will only need chapters, no section etc. I would also like to have dots to to go from Anhang 1: Chapter Name ..... page number, so it matches my listoffigures, listofequations and listoftables.

I am also using custom headers which should show

Anhang 1

not the Full chapter name if possible.

Here is the MWE:

    \documentclass[12pt, numbers=noenddot,parskip, headsepline, footsepline,headings=small,]{scrreprt}

\usepackage{lipsum}
\usepackage[a4paper, includeheadfoot, left=3.5cm, right=1.7cm, top=2.5cm, bottom=2.0cm]{geometry}
\renewcommand{\floatpagefraction}{.75}%



\newcommand\appendicesname{Anlagen}
\newcommand\listofloaname{Verzeichnis der \appendicesname}
\newcommand*{\listofappendices}{\listoftoc{loa}}
\setuptoc{loa}{totoc}

\makeatletter
\g@addto@macro\appendix{%
\let\oldaddcontentsline\addcontentsline
\newcommand\hackedaddcontentsline[3]{\oldaddcontentsline{loa}{#2}{#3}}
\let\oldpart\part
\renewcommand*\part[1]{%
  \let\addcontentsline\hackedaddcontentsline%
  \oldpart{#1}%
  \let\addcontentsline\oldaddcontentsline%
}
\let\oldchapter\chapter
\renewcommand*\chapter[1]{%
  \let\addcontentsline\hackedaddcontentsline%
  \oldchapter{#1}%
  \let\addcontentsline\oldaddcontentsline%
}
\let\oldsection\section
\renewcommand*\section[1]{%
  \let\addcontentsline\hackedaddcontentsline%
  \oldsection{#1}%
  \let\addcontentsline\oldaddcontentsline%
}
\let\oldsubsection\subsection
\renewcommand*\subsection[1]{%
  \let\addcontentsline\hackedaddcontentsline%
  \oldsubsection{#1}%
  \let\addcontentsline\oldaddcontentsline%
}
\let\oldsubsubsection\subsubsection
\renewcommand*\subsubsection[1]{%
  \let\addcontentsline\hackedaddcontentsline%
  \oldsubsubsection{#1}%
  \let\addcontentsline\oldaddcontentsline%
}
}
\makeatother

\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{equation}{chapter}
\counterwithout{table}{chapter}

\usepackage{etoolbox,refcount}
\usepackage{multicol}


\usepackage[onehalfspacing]{setspace}
\usepackage[ngerman]{babel}




\usepackage{xpatch}



%\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
%\usepackage{mathpazo}
\usepackage[automark]{scrlayer-scrpage}
\automark{chapter}

\clearpairofpagestyles
\ihead{\headmark}
\ohead{\pagemark}
\renewcommand*{\chapterpagestyle}{headings}
\renewcommand*{\chapterheadstartvskip}{\vspace*{-\topskip}}

\renewcommand{\theequation}{\arabic{equation}}
\renewcommand{\thefigure}{\arabic{figure}}
\renewcommand{\thetable}{\arabic{figure}}
\renewcommand{\topfraction}{.75}
\usepackage{enumitem}
\SetLabelAlign{LeftAlignFullWidth}{\makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}}

\usepackage[colorlinks=true, linktocpage=true,citecolor=blue]{hyperref}

\usepackage{xcolor}
\usepackage{microtype}
\usepackage{dirtytalk}

\usepackage{graphicx}
%\usepackage{ltxtable}
%\usepackage{mathpazo}


\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}


\usepackage[nottoc]{tocbibind}
\usepackage[titles]{tocloft}



\newcommand\NoIndent[1]{%
    \par\vbox{\parbox[t]{\linewidth}{#1}}%
}


\begin{document}

\renewcommand{\cftdot}{.}   



\newcounter{savepage}
\pagenumbering{Roman}



%\cleardoublepage
\onehalfspacing
\tableofcontents
\KOMAoptions{listof=totoc,index=totoc}

\setcounter{savepage}{\value{page}}
\pagenumbering{arabic}

\chapter{Chapter 1}

\lipsum[1-5]

\section{A section}

\lipsum[1-5]

\listofappendices

\appendix
\renewcommand{\thechapter}{Anhang~\arabic{chapter}}
\chapter{This is the first Anhang}


\end{document}

UPDATE: NEW MWE adopting answer:

\documentclass[12pt, numbers=noenddot,parskip, headsepline, footsepline,headings=small,
listof=totoc,
index=totoc
]{scrreprt}

\usepackage[a4paper, includeheadfoot, left=3.5cm, right=1.7cm, top=2.5cm, bottom=2.0cm]{geometry}
\renewcommand{\floatpagefraction}{.75}%

\newcommand*{\listappendicesname}{Verzeichnis der Anlagen}

%%% see: https://komascript.de/comment/5578#comment-5578 (Markus Kohm)
\DeclareNewTOC[%
owner=\jobname,
listname=\listappendicesname,% 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}%
    }
}{}

\AfterTOCHead[atoc]{%
    % add the appendix TOC to the main TOC:
    {\def\ext@toc{toc}\addchaptertocentry{}{\listappendicesname}}
    \KOMAoptions{toc=nonumberline}
}
\makeatother

\usepackage{xpatch}% loads also etoolbox
\xapptocmd{\appendix}
{
    \useappendixtoc
    \listofatocs
    \renewcommand\chapterformat{\appendixname\ \thechapter:\enskip}%
    \renewcommand\thechapter{\arabic{chapter}}%
    \xpatchcmd{\addchaptertocentry}
    {\addtocentrydefault{chapter}{#1}{#2}}
    {\addtocentrydefault{chapter}{}{\appendixname\ #1:\ #2}}
    {}{\PatchFailed}
    \renewcommand\chaptermark[1]{\markboth{\chaptermarkformat}{\chaptermarkformat}}
    \renewcommand\chaptermarkformat{\appendixname\ \thechapter\autodot}
}
{}{\PatchFailed}


\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{equation}{chapter}
\counterwithout{table}{chapter}

\usepackage{refcount}
\usepackage{multicol}

\usepackage[onehalfspacing]{setspace}
\usepackage[ngerman]{babel}
\usepackage{blindtext}% only for dummy text

\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings; headings is only a synonym
\automark[chapter]{chapter}
\clearpairofpagestyles
\ihead{\headmark}
\ohead{\pagemark}

\RedeclareSectionCommand[beforeskip=-1sp minus -1sp]{chapter}% no skip before the chapter title

\renewcommand{\topfraction}{.75}
\usepackage{enumitem}
\SetLabelAlign{LeftAlignFullWidth}{\makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}}

\usepackage{xcolor}
\usepackage{microtype}
\usepackage{dirtytalk}% in TeXLive but not in MiKTeX

\usepackage{graphicx}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[colorlinks=true, linktocpage=true,citecolor=blue]{hyperref}% load as last package

\newcommand\NoIndent[1]{%
    \par\vbox{\parbox[t]{\linewidth}{#1}}%
}
\newcounter{savepage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Added To MWE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}

\DeclareNewTOC[%
tocentryindent=0pt,% kein Einzug im Verzeichnis
tocentrynumwidth=2em,% Einzug für den Text im Verzeichnis
type=equation
]{loe}
\AtBeginDocument{\renewcaptionname{ngerman}{\contentsname}{Inhalt}
    \newcaptionname{ngerman}\equationname{Formel}% 
    \newcaptionname{ngerman}\listequationname{Verzeichnis der Formeln}
    \renewcaptionname{ngerman}{\listfigurename}{Verzeichnis der Abbildungen}    %Figures
    \renewcaptionname{ngerman}{\listtablename}{Verzeichnis der Tabellen}        %Tables
    \renewcaptionname{ngerman}{\figurename}{Abb.}               %Figure
    \renewcaptionname{ngerman}{\tablename}{Tab.}                %Table
    \renewcaptionname{ngerman}{\bibname}{Verzeichnis der Literatur}             %Bibliography
    \newcaptionname{ngerman}{\lstlistlistingname}{Quelltexte} %Table of listings 
    \newcaptionname{ngerman}{\lstlistingname}{Quelltext}  }%


\makeatletter
\newcommand*{\@currententry}{}
% Zwei amsmath-Anweisungen ändern:
\g@addto@macro\make@display@tag{\set@currententry}%
\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}%
    \set@currententry}
\newcommand*{\set@currententry}{%
    \typeout{set current entry}%
    \ifx\@currententry\@empty\else
    \addcontentsline{loe}{equation}{\protect\numberline{\@currentlabel}%
        \@currententry}%
    \global\let\@currententry\@empty
    \fi
}
% Neue Benutzeranweisung
\newcommand*{\equationentry}[1]{%
    \gdef\@currententry{#1}%
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Added To MWE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
    \pagenumbering{Roman}
\tableofcontents
\listofequations
\listoffigures
\listoftables
    \setcounter{savepage}{\value{page}}

    \cleardoublepage
    \pagenumbering{arabic}

    %   \blinddocument
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %Added To MWE
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \chapter{Kapitel 1}
    \begin{equation}\label{eq:Eq1}\equationentry{P-Anteil}
    a=b
    \end{equation}
    \newpage

    \centering% center the table
    \captionaboveof{table}{My caption}
    \label{my-label}
    \begin{tabular}{lllll}
        & \multicolumn{2}{l}{XYZ} & \multicolumn{2}{l}{ABC} \\
        & Sex         & P         & Sex         & P         \\
        AGE1 & 0.5         & 1         & 0.6         & 1         \\
        &             &           &             &          
    \end{tabular}


    \begin{figure}
        Test Figure
        \caption{No Intend Here} \label{fig:LableTest}
    \end{figure}

    \begin{figure}
    Test Figure
    \caption{No Intend Here} \label{fig:LableTest2}
\end{figure}
%   \blinddocument
        \begin{equation}\label{eq:Eq2}\equationentry{P-Anteil}
    a=b
    \end{equation}

        \begin{equation}\label{eq:3}\equationentry{P-Anteil}
    a=b
    \end{equation}

    \chapter{Kapitel 2}

            \begin{equation}\label{eq:Eq4}\equationentry{P-Anteil}
    a=b
    \end{equation}

    \begin{equation}\label{eq:5}\equationentry{P-Anteil}
    a=b
    \end{equation}

        \centering% center the table
    \captionaboveof{table}{My caption}
    \label{my-label2}
    \begin{tabular}{lllll}
        & \multicolumn{2}{l}{XYZ} & \multicolumn{2}{l}{ABC} \\
        & Sex         & P         & Sex         & P         \\
        AGE1 & 0.5         & 1         & 0.6         & 1         \\
        &             &           &             &          
    \end{tabular}


    \begin{figure}
        Test Figure
        \caption{No Intend Here} \label{fig:LableTest3}
    \end{figure}
    \blinddocument
    \appendix



\end{document}

1 Answer 1

2

Do not use package tocloft together with a KOMA-Script class. There is also no need to load package tocbibind.

Suggestion:

\documentclass[12pt, numbers=noenddot,parskip, headsepline, footsepline,headings=small,
  listof=totoc,
  index=totoc
]{scrreprt}

\usepackage[a4paper, includeheadfoot, left=3.5cm, right=1.7cm, top=2.5cm, bottom=2.0cm]{geometry}
\renewcommand{\floatpagefraction}{.75}%

\newcommand*{\listappendicesname}{Verzeichnis der Anlagen}

%%% see: https://komascript.de/comment/5578#comment-5578 (Markus Kohm)
\DeclareNewTOC[%
  owner=\jobname,
  listname=\listappendicesname,% 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}%
  }
}{}

\AfterTOCHead[atoc]{%
  % add the appendix TOC to the main TOC:
  {\def\ext@toc{toc}\addchaptertocentry{}{\listappendicesname}}
  \KOMAoptions{toc=nonumberline}
}
\makeatother

\usepackage{xpatch}% loads also etoolbox
\xapptocmd{\appendix}
  {
  \useappendixtoc
  \listofatocs
  \renewcommand\chapterformat{\appendixname\ \thechapter:\enskip}%
  \renewcommand\thechapter{\arabic{chapter}}%
  \xpatchcmd{\addchaptertocentry}
      {\addtocentrydefault{chapter}{#1}{#2}}
      {\addtocentrydefault{chapter}{}{\appendixname\ #1:\ #2}}
      {}{\PatchFailed}
  \renewcommand\chaptermark[1]{\markboth{\chaptermarkformat}{\chaptermarkformat}}
  \renewcommand\chaptermarkformat{\appendixname\ \thechapter\autodot}
  }
  {}{\PatchFailed}


\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{equation}{chapter}
\counterwithout{table}{chapter}

\usepackage{refcount}
\usepackage{multicol}

\usepackage[onehalfspacing]{setspace}
\usepackage[ngerman]{babel}
\usepackage{blindtext}% only for dummy text

\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings; headings is only a synonym
\automark[chapter]{chapter}
\clearpairofpagestyles
\ihead{\headmark}
\ohead{\pagemark}

\RedeclareSectionCommand[beforeskip=-1sp minus -1sp]{chapter}% no skip before the chapter title

\renewcommand{\topfraction}{.75}
\usepackage{enumitem}
\SetLabelAlign{LeftAlignFullWidth}{\makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}}

\usepackage{xcolor}
\usepackage{microtype}
\usepackage{dirtytalk}% in TeXLive but not in MiKTeX

\usepackage{graphicx}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[colorlinks=true, linktocpage=true,citecolor=blue]{hyperref}% load as last package

\newcommand\NoIndent[1]{%
    \par\vbox{\parbox[t]{\linewidth}{#1}}%
}
\newcounter{savepage}

\begin{document}
\pagenumbering{Roman}
\tableofcontents
\listoffigures
\listoftables
\setcounter{savepage}{\value{page}}

\cleardoublepage
\pagenumbering{arabic}
\blinddocument

\appendix
\blinddocument
\end{document}

enter image description here

enter image description here

enter image description here

enter image description here

5
  • This is great! Thank you so mich for your effort, I appreciate it! Could you have a look at my updated MWE with your solution + and added list of equations? I would need the listoffig and listoftab to be formatted the same way, basically without the intend of each separate line. Would there be a possibility to have to chapter gab between each element, as it somehow makes no sense without the chapter sensitive numbering of elements. Jul 18, 2017 at 9:54
  • I think, asking a follow up question with a link to this question here would be better then editing the oirginal question. And maybe you can accept the answer if it solves your original issue.
    – esdd
    Jul 18, 2017 at 11:00
  • Done: tex.stackexchange.com/questions/381149/… Jul 18, 2017 at 11:15
  • Maybe one more small follow up q: Is there a way to get the chapter headings for the Appendix even smaller, so I have more space for my appendix items? Jul 18, 2017 at 14:42
  • Posted it here: tex.stackexchange.com/questions/381190/… Jul 18, 2017 at 15:12

You must log in to answer this question.

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