von HenningSch » Di 7. Mai 2019, 16:52
Hallo zusammen,
ich möchte die Bezeichnung der Querverweise mit
\autoref ändern, wenn auf ein Kapitel des Anhangs verwiesen wird. Ich habe schon diese Anweisungen gefunden:
\addto\extrasngerman{%
\renewcommand{\sectionautorefname}{Kapitel}%
\let\subsectionautorefname\sectionautorefname%
\let\subsubsectionautorefname\sectionautorefname%
\let\subsubsubsectionautorefname\sectionautorefname%
}
Wie ihr sicher an dem Codeschnipsel schon gesehen habt, brauche ich auch eine 4. Ebene im Inhaltsverzeichnis (inwiefern das für das Problem relevant ist, weiß ich nicht, daher lasse ich es mal drin.)
Das Problem, vor dem ich jetzt stehe, ist, dass ich Kapitel
vor dem Anhang mit "Kapitel"
in dem Anhang mit "Anhang"
nach dem Anhang wieder mit "Kapitel"
referenzieren soll.
Ich habe ein kleines Beispiel gemacht, das die Problematik, denke ich, gut verdeutlicht und hoffe ihr könnt mir helfen:
\documentclass[12pt]{scrartcl}
\usepackage[ngerman]{babel} % Silbentrennung
\usepackage[utf8]{inputenc} % Utf8-Kodierung für Umlaute usw
\usepackage[T1]{fontenc} % Ligaturen, richtige Umlaute im PDF
\usepackage{blindtext}
\usepackage{hyperref}
% 4. Ebene der Überschriften
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\setkomafont{sectionentrypagenumber}{\rmfamily\normalfont}
\RedeclareSectionCommands[
level=5,
toclevel=5,
increaselevel=1
]{paragraph,subparagraph}
\DeclareNewSectionCommand[
style=section,
level=4,
counterwithin=subsubsection,
indent=0pt,
beforeskip=-3.25ex plus -1ex minus -0.2ex,
afterskip=1.5ex plus .2ex,
font=\normalfont\bfseries\large,
toclevel=4,
tocindent=7em,
tocnumwidth=4.1em
]{subsubsubsection}
% Anhangsverzeichnis (nach https://komascript.de/comment/5578#comment-5578)
\makeatletter
\DeclareNewTOC[owner=\jobname,listname={Anhang},name={Anhang}]{atoc}
\AfterTOCHead[atoc]{\let\if@dynlist\if@tocleft}
\newcommand*{\useappendixtoc}{%
\renewcommand*{\ext@toc}{atoc}%
\scr@ifundefinedorrelax{hypersetup}{}{%
\hypersetup{bookmarkstype=atoc}%
}%
}
\setuptoc{atoc}{totoc}
\newcommand*{\usestandardtoc}{%
\renewcommand*{\ext@toc}{toc}%
\scr@ifundefinedorrelax{hypersetup}{}{%
\hypersetup{bookmarkstype=toc}%
}%
}
\makeatother
\usepackage{xpatch}
\xapptocmd\appendix{%
\listofatocs%
\useappendixtoc%
% Katitelnummerierungen ändern
\renewcommand*{\thesubsection}{\Alph{section}.\Roman{subsection}}%
\renewcommand*{\thesubsubsection}{\Alph{section}.\Roman{subsection}.\alph{subsubsection}}%
\renewcommand*{\thesubsubsubsection}{\Alph{section}.\Roman{subsection}.\alph{subsubsection}.\roman{subsubsubsection}}%
\newpage%
}{}{}
\newcommand{\postappendix}{%
\usestandardtoc%
% Katitelnummerierungen ändern
\renewcommand{\thesection}{\arabic{section}}%
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}%
\renewcommand{\thesubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}%
\renewcommand{\thesubsubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{subsubsubsection}}%
}
% Autorefbezeichnung ändern
\addto\extrasngerman{%
\renewcommand{\sectionautorefname}{Kapitel}%
\let\subsectionautorefname\sectionautorefname%
\let\subsubsectionautorefname\sectionautorefname%
\let\subsubsubsectionautorefname\sectionautorefname%
}
\newcommand{\reftab}{%
\begin{tabular}{|p{0.3\linewidth}|p{0.3\linewidth}|p{0.3\linewidth}|}
\hline
\textbf{Ebene} & \textbf{erwartet} & \textbf{tatsächlich} \\ \hline
section & Kapitel 1 & \autoref{sec:Kapitel 1} \\ \hline
subsection & Kapitel 1.1 & \autoref{sec:Kapitel 1.1} \\ \hline
subsubsection & Kapitel 1.1.1 & \autoref{sec:Kapitel 1.1.1} \\ \hline
subsubsubsection & Kapitel 1.1.1.1 & \autoref{sec:Kapitel 1.1.1.1} \\ \hline
section & Anhang A & \autoref{sec:Anhang A} \\ \hline
subsection & Anhang A.I & \autoref{sec:Anhang A.I} \\ \hline
subsubection & Anhang A.I.a & \autoref{sec:Anhang A.I.a} \\ \hline
subsubsubection & Anhang A.I.a.i & \autoref{sec:Anhang A.I.a.i} \\ \hline
section & Kapitel 2 & \autoref{sec:Kapitel 2} \\ \hline
subsection & Kapitel 2.1 & \autoref{sec:Kapitel 2.1} \\ \hline
subsubsection & Kapitel 2.1.1 & \autoref{sec:Kapitel 2.1.1} \\ \hline
subsubsubsection & Kapitel 2.1.1.1 & \autoref{sec:Kapitel 2.1.1.1} \\ \hline
\end{tabular}
}
\begin{document}
\tableofcontents
\newpage
\section{Kapitel 1}\label{sec:Kapitel 1}
\reftab
\subsection{Kapitel 1.1}\label{sec:Kapitel 1.1}
\reftab
\subsubsection{Kapitel 1.1.1}\label{sec:Kapitel 1.1.1}
\reftab
\subsubsubsection{Kapitel 1.1.1.1}\label{sec:Kapitel 1.1.1.1}
\reftab
\newpage
\appendix
\section{Anhang A}\label{sec:Anhang A}
\reftab
\subsection{Anhang A.I}\label{sec:Anhang A.I}
\reftab
\subsubsection{Anhang A.I.a}\label{sec:Anhang A.I.a}
\reftab
\subsubsubsection{Anhang A.I.a.i}\label{sec:Anhang A.I.a.i}
\reftab
\newpage
\postappendix
\section{Post-Anhang 2}\label{sec:Kapitel 2}
\reftab
\subsection{Post-Anhang 2.1}\label{sec:Kapitel 2.1}
\reftab
\subsubsection{Post-Anhang 2.1.1}\label{sec:Kapitel 2.1.1}
\reftab
\subsubsubsection{Post-Anhang 2.1.1.1}\label{sec:Kapitel 2.1.1.1}
\reftab
\end{document}
Ich habe einmal versucht die Bezeichnung beim Umschalten der Verzeichnisse wieder zu ändern (ohne Erfolg):
\usepackage{xpatch}
\xapptocmd\appendix{%
\listofatocs%
\useappendixtoc%
% Katitelnummerierungen ändern
\renewcommand*{\thesubsection}{\Alph{section}.\Roman{subsection}}%
\renewcommand*{\thesubsubsection}{\Alph{section}.\Roman{subsection}.\alph{subsubsection}}%
\renewcommand*{\thesubsubsubsection}{\Alph{section}.\Roman{subsection}.\alph{subsubsection}.\roman{subsubsubsection}}%
\newpage%
% Autorefbezeichnung ändern
\addto\extrasngerman{%
\renewcommand{\sectionautorefname}{Anhang}%
\let\subsectionautorefname\sectionautorefname%
\let\subsubsectionautorefname\sectionautorefname%
\let\subsubsubsectionautorefname\sectionautorefname%
}
}{}{}
Hallo zusammen,
ich möchte die Bezeichnung der Querverweise mit [i]\autoref[/i] ändern, wenn auf ein Kapitel des Anhangs verwiesen wird. Ich habe schon diese Anweisungen gefunden:
[code]
\addto\extrasngerman{%
\renewcommand{\sectionautorefname}{Kapitel}%
\let\subsectionautorefname\sectionautorefname%
\let\subsubsectionautorefname\sectionautorefname%
\let\subsubsubsectionautorefname\sectionautorefname%
}
[/code]
Wie ihr sicher an dem Codeschnipsel schon gesehen habt, brauche ich auch eine 4. Ebene im Inhaltsverzeichnis (inwiefern das für das Problem relevant ist, weiß ich nicht, daher lasse ich es mal drin.)
Das Problem, vor dem ich jetzt stehe, ist, dass ich Kapitel
[u]vor[/u] dem Anhang mit "Kapitel"
[u]in[/u] dem Anhang mit "Anhang"
[u]nach[/u] dem Anhang wieder mit "Kapitel"
referenzieren soll.
Ich habe ein kleines Beispiel gemacht, das die Problematik, denke ich, gut verdeutlicht und hoffe ihr könnt mir helfen:
[code]
\documentclass[12pt]{scrartcl}
\usepackage[ngerman]{babel} % Silbentrennung
\usepackage[utf8]{inputenc} % Utf8-Kodierung für Umlaute usw
\usepackage[T1]{fontenc} % Ligaturen, richtige Umlaute im PDF
\usepackage{blindtext}
\usepackage{hyperref}
% 4. Ebene der Überschriften
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\setkomafont{sectionentrypagenumber}{\rmfamily\normalfont}
\RedeclareSectionCommands[
level=5,
toclevel=5,
increaselevel=1
]{paragraph,subparagraph}
\DeclareNewSectionCommand[
style=section,
level=4,
counterwithin=subsubsection,
indent=0pt,
beforeskip=-3.25ex plus -1ex minus -0.2ex,
afterskip=1.5ex plus .2ex,
font=\normalfont\bfseries\large,
toclevel=4,
tocindent=7em,
tocnumwidth=4.1em
]{subsubsubsection}
% Anhangsverzeichnis (nach https://komascript.de/comment/5578#comment-5578)
\makeatletter
\DeclareNewTOC[owner=\jobname,listname={Anhang},name={Anhang}]{atoc}
\AfterTOCHead[atoc]{\let\if@dynlist\if@tocleft}
\newcommand*{\useappendixtoc}{%
\renewcommand*{\ext@toc}{atoc}%
\scr@ifundefinedorrelax{hypersetup}{}{%
\hypersetup{bookmarkstype=atoc}%
}%
}
\setuptoc{atoc}{totoc}
\newcommand*{\usestandardtoc}{%
\renewcommand*{\ext@toc}{toc}%
\scr@ifundefinedorrelax{hypersetup}{}{%
\hypersetup{bookmarkstype=toc}%
}%
}
\makeatother
\usepackage{xpatch}
\xapptocmd\appendix{%
\listofatocs%
\useappendixtoc%
% Katitelnummerierungen ändern
\renewcommand*{\thesubsection}{\Alph{section}.\Roman{subsection}}%
\renewcommand*{\thesubsubsection}{\Alph{section}.\Roman{subsection}.\alph{subsubsection}}%
\renewcommand*{\thesubsubsubsection}{\Alph{section}.\Roman{subsection}.\alph{subsubsection}.\roman{subsubsubsection}}%
\newpage%
}{}{}
\newcommand{\postappendix}{%
\usestandardtoc%
% Katitelnummerierungen ändern
\renewcommand{\thesection}{\arabic{section}}%
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}%
\renewcommand{\thesubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}%
\renewcommand{\thesubsubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{subsubsubsection}}%
}
% Autorefbezeichnung ändern
\addto\extrasngerman{%
\renewcommand{\sectionautorefname}{Kapitel}%
\let\subsectionautorefname\sectionautorefname%
\let\subsubsectionautorefname\sectionautorefname%
\let\subsubsubsectionautorefname\sectionautorefname%
}
\newcommand{\reftab}{%
\begin{tabular}{|p{0.3\linewidth}|p{0.3\linewidth}|p{0.3\linewidth}|}
\hline
\textbf{Ebene} & \textbf{erwartet} & \textbf{tatsächlich} \\ \hline
section & Kapitel 1 & \autoref{sec:Kapitel 1} \\ \hline
subsection & Kapitel 1.1 & \autoref{sec:Kapitel 1.1} \\ \hline
subsubsection & Kapitel 1.1.1 & \autoref{sec:Kapitel 1.1.1} \\ \hline
subsubsubsection & Kapitel 1.1.1.1 & \autoref{sec:Kapitel 1.1.1.1} \\ \hline
section & Anhang A & \autoref{sec:Anhang A} \\ \hline
subsection & Anhang A.I & \autoref{sec:Anhang A.I} \\ \hline
subsubection & Anhang A.I.a & \autoref{sec:Anhang A.I.a} \\ \hline
subsubsubection & Anhang A.I.a.i & \autoref{sec:Anhang A.I.a.i} \\ \hline
section & Kapitel 2 & \autoref{sec:Kapitel 2} \\ \hline
subsection & Kapitel 2.1 & \autoref{sec:Kapitel 2.1} \\ \hline
subsubsection & Kapitel 2.1.1 & \autoref{sec:Kapitel 2.1.1} \\ \hline
subsubsubsection & Kapitel 2.1.1.1 & \autoref{sec:Kapitel 2.1.1.1} \\ \hline
\end{tabular}
}
\begin{document}
\tableofcontents
\newpage
\section{Kapitel 1}\label{sec:Kapitel 1}
\reftab
\subsection{Kapitel 1.1}\label{sec:Kapitel 1.1}
\reftab
\subsubsection{Kapitel 1.1.1}\label{sec:Kapitel 1.1.1}
\reftab
\subsubsubsection{Kapitel 1.1.1.1}\label{sec:Kapitel 1.1.1.1}
\reftab
\newpage
\appendix
\section{Anhang A}\label{sec:Anhang A}
\reftab
\subsection{Anhang A.I}\label{sec:Anhang A.I}
\reftab
\subsubsection{Anhang A.I.a}\label{sec:Anhang A.I.a}
\reftab
\subsubsubsection{Anhang A.I.a.i}\label{sec:Anhang A.I.a.i}
\reftab
\newpage
\postappendix
\section{Post-Anhang 2}\label{sec:Kapitel 2}
\reftab
\subsection{Post-Anhang 2.1}\label{sec:Kapitel 2.1}
\reftab
\subsubsection{Post-Anhang 2.1.1}\label{sec:Kapitel 2.1.1}
\reftab
\subsubsubsection{Post-Anhang 2.1.1.1}\label{sec:Kapitel 2.1.1.1}
\reftab
\end{document}
[/code]
Ich habe einmal versucht die Bezeichnung beim Umschalten der Verzeichnisse wieder zu ändern (ohne Erfolg):
[code]
\usepackage{xpatch}
\xapptocmd\appendix{%
\listofatocs%
\useappendixtoc%
% Katitelnummerierungen ändern
\renewcommand*{\thesubsection}{\Alph{section}.\Roman{subsection}}%
\renewcommand*{\thesubsubsection}{\Alph{section}.\Roman{subsection}.\alph{subsubsection}}%
\renewcommand*{\thesubsubsubsection}{\Alph{section}.\Roman{subsection}.\alph{subsubsection}.\roman{subsubsubsection}}%
\newpage%
% Autorefbezeichnung ändern
\addto\extrasngerman{%
\renewcommand{\sectionautorefname}{Anhang}%
\let\subsectionautorefname\sectionautorefname%
\let\subsubsectionautorefname\sectionautorefname%
\let\subsubsubsectionautorefname\sectionautorefname%
}
}{}{}
[/code]