9

I'm using the document class scrartcl and appendix. This currently results in a letter instead of a number for section enumeration in the TOC and section title ("A My Code Listing"). I need to change this to "Appendix A My Code Listing", i.e. add the word "Appendix" to the section title.

I have found a manual workaround on http://web.reed.edu/cis/help/latex/thesis#appendices but would like to know if there is a way to change this automatically.

2
  • should it as "Appendix ..." in the table of contents, too?
    – user2478
    Commented Jan 7, 2011 at 13:43
  • 1
    Actually, there should be a seperate table of contents for the appendices. But I'm not into LaTeX so much, so I cannot make much of tex.stackexchange.com/questions/8211/list-of-appendices.
    – None
    Commented Jan 7, 2011 at 13:53

3 Answers 3

8
\documentclass[toc=left]{scrartcl}

\begin{document}
\tableofcontents

\section{foo} bar

\appendix
\gdef\thesection{Appendix \Alph{section}}
\section{foo} bar
\section{foo} bar

\end{document}
2
  • 4
    One should note, that this also adds “Appendix” to every reference to an appendix (e.g. in the toc or via \ref).
    – Caramdir
    Commented Jan 7, 2011 at 16:55
  • @Caramdir As well as to subsections of appendices. It also seems to mess up the spacing in the toc, i.e. the extra space required by "Appendix" is not accounted for.
    – Janosh
    Commented Jun 1, 2017 at 14:46
7

KOMA-Script has a mechanism for this. If you use scrreprt or scrbook, then you only need to add the appendixprefix option to \documentclass. For scrartcl, there is a description in the manual (section 16.3 “Expert Commands”): Just add

\usepackage{ifthen}

\newcommand*{\appendixmore}{%
  \renewcommand*{\othersectionlevelsformat}[1]{%
    \ifthenelse{\equal{##1}{section}}{\appendixname~}{}%
    \csname the##1\endcsname\autodot\enskip}
  \renewcommand*{\sectionmarkformat}{%
    \appendixname~\thesection\autodot\enskip}
}

to your preamble.

2
  • The appendixmore trick does not appear to be working in recent version of KOMA (3.19a). Commented Jun 16, 2016 at 16:53
  • With current version replace \renewcommand*{\othersectionlevelsformat}{…} with \renewcommand*{\sectionformat}{\appendixname~\thesection\autodot\enskip} Commented Mar 7, 2017 at 11:13
-1

You should use \KOMAoptions{appendixprefix=true}. This behavior is documented in the KOMA-Script guide, as scrartcl is part of KOMA-Script. The \appendixmore-trick is not needed.

1

You must log in to answer this question.

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