0

I'm using the article class where appendices appear as

A Title of appendix

B Another title

etc.

However, I'd like to have the appendices displayed as follows:

Anhang I

Anhang II

etc.

in the ToC and followed by the respective appendix title in the document. Changing the name is presumably not too hard using \appendixname after activating it for the article class (which I don't know how to do). However, I don't know how to obtain roman numbering.

Any advice is much appreciated.

Here a MWE:

\documentclass{article}

\usepackage{blindtext}

\begin{document}

  \tableofcontents

  \appendix

  \section{The first appendix}
  \blindtext

  \section{The second appendix}
  \blindtext

\end{document}
2
  • Appendix sections in the body should also use Roman numbering, as in the table of contents?
    – Bernard
    Jul 15, 2020 at 14:29
  • @Bernard Yes it should. In the body it should read the same as in the ToC but followed by the actual title of the respective appendix.
    – JDecou
    Jul 15, 2020 at 19:24

1 Answer 1

2

I hope that this does what you want.

% appnameprob.tex  SE 553677

\documentclass{article}
\usepackage{blindtext}

\usepackage{tocloft} % useful for controlling the ToC etc

\begin{document}

  \tableofcontents

\section{First section}
\blindtext

\section{Second section}
\blindtext

  \appendix

\renewcommand{\thesection}{Anhang \Roman{section}} % change the numbering scheme
\addtocontents{toc}{\setlength{\cftsecnumwidth}{6em}} % increase the space in the TOC for the number

  \section{The first appendix} \label{appone}
  \blindtext

  The next appendix is \ref{apptwo}.

  \section{The second appendix} \label{apptwo}
  \blindtext

  The first appendix was \ref{appone}.

\end{document}

It is a modified version of your MWE, for which thank you.

Following your and Donald Arseneau's comments I have added a second answer using the appendix package.

% appnameprob2.tex  SE 553677

\documentclass{article}
\usepackage{blindtext}

\usepackage{appendix}

\begin{document}

  \tableofcontents

\section{First section}
\blindtext

\section{Second section}
\blindtext

% the next commands are from the appendix package
\renewcommand{\appendixname}{Anhang} 
\appendixtitleon    % puts \appendixname before each appendix title
\appendixtitletocon % puts \appendixname before each TOC entry

\begin{appendices}

\renewcommand{\thesection}{\Roman{section}} % change the numbering scheme

  \section[]{The first appendix} \label{appone} % empty title in the TOC
  \blindtext

  The next appendix is \ref{apptwo}.

  \section[]{The second appendix} \label{apptwo}
  \blindtext

  The first appendix was \ref{appone}.

\end{appendices}

\end{document}

Depending on your end goal you might want to use bits from both answers (the \ref results differ between the two answers).

4
  • Peter, you aren't recommending appendix.sty? I thought it handled things like this. Jul 17, 2020 at 0:09
  • @Peter Many thanks for your answer. It almost does what I want. In your example the appendix title appears in the ToC as well as in the body. However, in the ToC I only want it to say 'Anhang I', i.e. no appendix title.
    – JDecou
    Jul 17, 2020 at 8:17
  • @DonaldArseneau I have added a second answer using the appendix package. I had forgotten how comprehensive it was. Thanks for the reminder. Jul 17, 2020 at 17:20
  • @JDecou I have added a second answer that deals with your ToC requirement (and uses simpler code). Jul 17, 2020 at 17:22

You must log in to answer this question.

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