
Я хочу напечатать заголовки приложений с префиксом «Приложение А: [какое-то название]», «Приложение Б: [какое-то другое название]» ... .
Я использовал следующие определенные команды (исполняемый tex-document в конце):
\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}
}
Это работает для Title и заголовка, но в tableofcontents всегда есть "Appendix A". Как это исправить? Я пытался вручную задать tableofcontents-name с помощью []
, но это не сработало :/. Спасибо за помощь :)
Запускаемый tex-файл
\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}
решение1
Я не понимаю, почему вы используете такой сложный подход.
\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}
В любом случае переосмысление \appendix
— не лучший выбор.
решение2
Не устанавливайте счетчики внутри аргумента \addchap.
\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}
(Я не понимаю, зачем вы используете все эти дополнительные счетчики и почему вы не используете префиксы глав, предлагаемые KOMA-script, и почему вы используете «Anhang» в тексте, но «Appendix» в заголовке, но не изменили эту часть своего кода.)