1

I want to print my appendix-titles with the prefix "Appendix A: [some title]" , "Appendix B: [some other title]" ... .

I used the following defined commands (runnable tex-document at the end):

\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}
}

This works for the Title and the headline, but in the tableofcontents, there is always "Appendix A". How can i fix this? I tried to set the tableofcontents-name manually with [], but this didn't work :/. Thank you for helping :)

Runnable tex-file

\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}

2 Answers 2

1

I'm not sure why you're using such a complicated approach.

\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}

enter image description here

Redefining \appendix is not the best choice in any case.

1

Don't set the counters inside the argument of \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}

(I don't understand why you are using all this additional counters and why you don't use the chapter prefixes offered by KOMA-script, and why you use "Anhang" in the text, but "Appendix" in the header but didn't change this part of your code.)

3
  • Sorry, I missed to translate "Anhang" (german) into Appendix. Fixed :) Jul 29, 2015 at 7:17
  • With this solution, the number of the head and the number of the chapter gets out of sync Jul 29, 2015 at 7:42
  • Sorry, I forgot the \clearpage (but imho all the counters are unnecessary, but as I didn't understand what you are after ...). Jul 29, 2015 at 8:02

You must log in to answer this question.

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