
Ich möchte meine Anhangstitel mit dem Präfix „Anhang A: [ein Titel]“, „Anhang B: [ein anderer Titel]“ … drucken.
Ich habe die folgenden definierten Befehle verwendet (ausführbares Tex-Dokument am Ende):
\newcounter{rsss}
\DeclareRobustCommand{\appendixString}{
\setcounter{rsss}{\value{chapter}}
\addtocounter{rsss}{- \value{chapterCounter}}
Appendix\Alph{rsss} :
}
\DeclareRobustCommand{\appendixStringHeadline}{
\setcounter{rsss}{\value{chapter}}
\addtocounter{rsss}{- \value{chapterCounter}}
\addtocounter{rsss}{1}
Appendix \Alph{rsss} :
}
\DeclareRobustCommand{\appendix}[2]{
\addchap[\appendixStringHeadline #1]{\appendixStringHeadline #1}\label{#2}
\ihead{
\appendixString #1
}
\stepcounter{chapter}
}
Das funktioniert zwar für den Titel und die Überschrift, aber im Inhaltsverzeichnis steht immer "Anhang A". Wie kann ich das beheben? Ich habe versucht, den Inhaltsverzeichnisnamen manuell mit festzulegen []
, aber das hat nicht funktioniert :/. Danke für eure Hilfe :)
Ausführbare Tex-Datei
\documentclass{scrreprt}
\usepackage{scrpage2}\pagestyle{scrheadings}
\newcounter{chapterCounter}
\newcounter{rsss}
\DeclareRobustCommand{\appendixString}{
\setcounter{rsss}{\value{chapter}}
\addtocounter{rsss}{- \value{chapterCounter}}
Appendix \Alph{rsss} :
}
\DeclareRobustCommand{\appendixStringHeadline}{
\setcounter{rsss}{\value{chapter}}
\addtocounter{rsss}{- \value{chapterCounter}}
\addtocounter{rsss}{1}
Appendix \Alph{rsss} :
}
\DeclareRobustCommand{\appendix}[2]{
\addchap[\appendixStringHeadline #1]{\appendixStringHeadline #1}\label{#2}
\ihead{
\appendixString #1
}
\stepcounter{chapter}
}
\begin{document}
\tableofcontents
\chapter{ Bla}
\chapter{ Bla Bla}
\appendix{test 1}{bla bla}
\appendix{test 2}{bla}
\end{document}
Antwort1
Ich bin nicht sicher, warum Sie einen so komplizierten Ansatz verwenden.
\documentclass{scrreprt}
\usepackage{scrpage2}
\pagestyle{scrheadings}
\newcommand{\appendixString}{Appendix \thechapter: }
\newcommand{\addappendix}[1]{%
\refstepcounter{chapter}
\addchap{\appendixString #1}%
\ihead{\appendixString #1}%
}
\begin{document}
\tableofcontents
\chapter{Bla}
\chapter{Bla Bla}
\appendix
\addappendix{test 1}\label{bla bla}
\addappendix{test 2}\label{bla}
\end{document}
Eine Neudefinition \appendix
ist jedenfalls nicht die beste Wahl.
Antwort2
Legen Sie die Zähler nicht innerhalb des Arguments von \addchap fest.
\documentclass{scrreprt}
\usepackage{scrpage2}\pagestyle{scrheadings}
\newcounter{chapterCounter}
\newcounter{rsss}
\DeclareRobustCommand{\appendix}[2]{%
\clearpage
\setcounter{rsss}{\value{chapter}}%
\addtocounter{rsss}{- \value{chapterCounter}}%
\addtocounter{rsss}{1}%
\addchap[Anhang \Alph{rsss} : #1]{Anhang \Alph{rsss} : #1}\label{#2}
\ihead{%
Appendix \Alph{rsss} : #1
}%
\stepcounter{chapter}
}
\begin{document}
\tableofcontents
\chapter{ Bla}
\chapter{ Bla Bla}
\appendix{test 1}{bla bla}
\appendix{test 2}{bla}
\end{document}
(Ich verstehe nicht, warum Sie all diese zusätzlichen Zähler verwenden und warum Sie die von KOMA-script angebotenen Kapitelpräfixe nicht verwenden und warum Sie im Text „Anhang“, in der Kopfzeile jedoch „Appendix“ verwenden, diesen Teil Ihres Codes jedoch nicht geändert haben.)