Anhangsverzeichnis nicht eingerückt

Inhalt, Abbildungen, Tabellen, Quellcodes und andere Verzeichnisse


HenningSch
Forum-Newbie
Forum-Newbie
Beiträge: 6
Registriert: Di 30. Apr 2019, 15:46

Anhangsverzeichnis nicht eingerückt

Beitrag von HenningSch »

Hallo zusammen,

ich muss für meine Anhänge ein separates Verzeichnis erstellen. Das funktioniert soweit auch einwandfrei. Das Problem entsteht erst durch die Option listof=entryprefix. Dadurch verschwindet die Einrückung des Anhangsverzeichnisses leider. Ich habe versucht mich etwas bei tocbasic einzulesen, werde da aber nicht fündig. Hat jemand eine Idee?

Minimalbeispiel:
\documentclass[listof=totoc,listof=entryprefix]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{hyperref}
\usepackage{bookmark}

% Anhangsverzeichnis (nach https://komascript.de/comment/5578#comment-5578)
\DeclareNewTOC[owner=\jobname,listname={Anhang},name={Anhang}]{atoc}
\makeatletter
\newcommand*{\useappendixtoc}{%
	\renewcommand*{\ext@toc}{atoc}%
	\scr@ifundefinedorrelax{hypersetup}{}{
		\hypersetup{bookmarkstype=atoc}%
	}%
}
\newcommand*{\usestandardtoc}{%
	\renewcommand*{\ext@toc}{toc}%
	\scr@ifundefinedorrelax{hypersetup}{}{
		\hypersetup{bookmarkstype=toc}%
	}%
}
\makeatother

\usepackage{xpatch}
\xapptocmd\appendix{%
	\useappendixtoc%
	\listofatocs%
	\addcontentsline{toc}{section}{\appendixname}%
}{}{}
\newcommand{\postappendix}{%
	\usestandardtoc%
%	\bookmarksetup{startatroot}% siehe bookmark-Anleitung
}

% LoF
\renewcaptionname{ngerman}{\figurename}{Abb.}
\BeforeStartingTOC[lof]{\renewcommand*\autodot{:}}

\begin{document}
	\tableofcontents
	\listoffigures
	\newpage
	
	\section{Kapitel 1}
	\begin{figure}
		\centering 
		\rule{10cm}{3cm} 
		\caption{Testbild} 
	\end{figure}
	\subsection{Kapitel 1.1}
	\subsubsection{Kapitel 1.1.1}
	\newpage
	
	\appendix
	\section{Anhang A}
	\subsection{Anhang A.1}
	\subsubsection{Anhang A.1.1}
	\newpage
	
	\postappendix
	\section{Post-Anhang 1}
	\subsection{Post-Anhang 1.1}
	\subsubsection{Post-Anhang 1.1.1}
\end{document}

esdd
Forum-Meister
Forum-Meister
Beiträge: 2561
Registriert: So 7. Feb 2010, 16:36

Beitrag von esdd »

Die Option listof=entryprefix setzt außerdem automatisch auch listof=flat. Die Wirkung von listof=flat erstreckt sich allerdings nicht nur auf Listen mit owner=float, sondern auch auf alle anderen mit Ausnahme des Inhaltsverzeichnisses mit Endung toc.

Als Workaround kannst Du das folgende nutzen:
\documentclass[listof=totoc,listof=entryprefix]{scrartcl} 
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage[ngerman]{babel} 
\usepackage{hyperref} 
\usepackage{bookmark} 

% Anhangsverzeichnis (nach https://komascript.de/comment/5578#comment-5578) 

\DeclareNewTOC[owner=\jobname,listname={Anhang},name={Anhang}]{atoc}
\makeatletter
\AfterTOCHead[atoc]{\let\if@dynlist\if@tocleft}% <- ergänzt, gleiches Verhalten wie toc
\newcommand*{\useappendixtoc}{% 
   \renewcommand*{\ext@toc}{atoc}% 
   \scr@ifundefinedorrelax{hypersetup}{}{ 
      \hypersetup{bookmarkstype=atoc}% 
   }% 
} 
\newcommand*{\usestandardtoc}{% 
   \renewcommand*{\ext@toc}{toc}% 
   \scr@ifundefinedorrelax{hypersetup}{}{ 
      \hypersetup{bookmarkstype=toc}% 
   }% 
} 
\makeatother 

\usepackage{xpatch} 

\xapptocmd\appendix{% 
   \useappendixtoc% 
   \listofatocs% 
   \addcontentsline{toc}{section}{\appendixname}% 
}{}{} 
\makeatother
\newcommand{\postappendix}{% 
   \usestandardtoc% 
%   \bookmarksetup{startatroot}% siehe bookmark-Anleitung 
} 

% LoF 
\renewcaptionname{ngerman}{\figurename}{Abb.} 
\BeforeStartingTOC[lof]{\renewcommand*\autodot{:}} 

\begin{document} 
   \tableofcontents 
   \listoffigures 
   \newpage 
    
   \section{Kapitel 1} 
   \begin{figure} 
      \centering 
      \rule{10cm}{3cm} 
      \caption{Testbild} 
   \end{figure} 
   \subsection{Kapitel 1.1} 
   \subsubsection{Kapitel 1.1.1} 
   \newpage 
    
   \appendix 
   \section{Anhang A} 
   \subsection{Anhang A.1} 
   \subsubsection{Anhang A.1.1} 
   \newpage 
    
   \postappendix 
   \section{Post-Anhang 1} 
   \subsection{Post-Anhang 1.1} 
   \subsubsection{Post-Anhang 1.1.1} 
\end{document}
Alternativ kannst Du auch mit listof=gratuated das implizite listof=flat wieder aufheben und anschließend die Einträge für Abbildungen und Tabellen entsprechend anpassen:
\documentclass[listof=totoc,listof=entryprefix]{scrartcl}

\KOMAoptions{listof=graduated}% <- aufheben von listof=flat
\DeclareTOCStyleEntries[
  indent=0pt,% <- kein Einzug
  dynnumwidth% <- automatische Anpassung der benötigten Breite für die Eintragsnummern
]{default}{figure,table}

\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage[ngerman]{babel} 
\usepackage{hyperref} 
\usepackage{bookmark} 

% Anhangsverzeichnis (nach https://komascript.de/comment/5578#comment-5578) 
\DeclareNewTOC[owner=\jobname,listname={Anhang},name={Anhang}]{atoc} 
\makeatletter 
\newcommand*{\useappendixtoc}{% 
   \renewcommand*{\ext@toc}{atoc}% 
   \scr@ifundefinedorrelax{hypersetup}{}{ 
      \hypersetup{bookmarkstype=atoc}% 
   }% 
} 
\newcommand*{\usestandardtoc}{% 
   \renewcommand*{\ext@toc}{toc}% 
   \scr@ifundefinedorrelax{hypersetup}{}{ 
      \hypersetup{bookmarkstype=toc}% 
   }% 
} 
\makeatother 

\usepackage{xpatch} 

\xapptocmd\appendix{% 
   \useappendixtoc% 
   \listofatocs% 
   \addcontentsline{toc}{section}{\appendixname}% 
}{}{} 
\makeatother 
\newcommand{\postappendix}{% 
   \usestandardtoc% 
%   \bookmarksetup{startatroot}% siehe bookmark-Anleitung 
} 

% LoF 
\renewcaptionname{ngerman}{\figurename}{Abb.} 
\BeforeStartingTOC[lof]{\renewcommand*\autodot{:}} 


\begin{document} 
   \tableofcontents 
   \listoffigures 
   \newpage 
    
   \section{Kapitel 1} 
   \begin{figure} 
      \centering 
      \rule{10cm}{3cm} 
      \caption{Testbild} 
   \end{figure} 
   \subsection{Kapitel 1.1} 
   \subsubsection{Kapitel 1.1.1} 
   \newpage 
    
   \appendix 
   \section{Anhang A} 
   \subsection{Anhang A.1} 
   \subsubsection{Anhang A.1.1} 
   \newpage 
    
   \postappendix 
   \section{Post-Anhang 1} 
   \subsection{Post-Anhang 1.1} 
   \subsubsection{Post-Anhang 1.1.1} 
\end{document} 

HenningSch
Forum-Newbie
Forum-Newbie
Beiträge: 6
Registriert: Di 30. Apr 2019, 15:46

Beitrag von HenningSch »

Funktioniert. Dankeschön!

Antworten