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}

JDecou
  • 67
  • Appendix sections in the body should also use Roman numbering, as in the table of contents? – Bernard Jul 15 '20 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 '20 at 19:24

1 Answers1

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).

Peter Wilson
  • 28,066
  • Peter, you aren't recommending appendix.sty? I thought it handled things like this. – Donald Arseneau Jul 17 '20 at 00: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 '20 at 08:17
  • @DonaldArseneau I have added a second answer using the appendix package. I had forgotten how comprehensive it was. Thanks for the reminder. – Peter Wilson Jul 17 '20 at 17:20
  • @JDecou I have added a second answer that deals with your ToC requirement (and uses simpler code). – Peter Wilson Jul 17 '20 at 17:22