1

I'm writing a text using the documentclass report and I can't find a way to add appendices like this within the article class:

\documentclass{article}
\begin{document}
\tableofcontents
\section{First section}
\subsection{A subsection}
\appendix
\addcontentsline{toc}{section}{Appendices}
\section*{Appendices}
\section{First appendix}
\section{Second appendix}
\end{document}

What I would like is:
- A main section (not a chapter, except if it's too complicated to do) named : Appendices without any numbering here
- subsection for every new appendices, with numbering (or letters)

Like this:

Last chapter
Last section
Last subsection

Appendices (as a section*) \addcontentsline{toc}{section}{Appendices}
Appendix 1 (as a subsection) \addcontentsline{toc}{subsection}{Appendix 1}

Appendix 2 (as a subsection) \addcontentsline{toc}{subsection}{Appendix 2}

Appendix 3 (as a subsection) \addcontentsline{toc}{subsection}{Appendix 3}

I would also like to refer to the appendices (with a \label{stuff}) in the main text regarding their number (or letter, I don't really care here).
Every try I've done ended with strange numbering begin either with a dot like this .1 or with .0.1. Thanks.

Update: This is almost working:

\documentclass{article}
\begin{document}
\tableofcontents
\section{First section}
\subsection{A subsection}
\appendix
\addcontentsline{toc}{section}{Appendices}
\section*{Appendices}
\renewcommand{\thesubsection}{\Alph{subsection}}
\section{First appendix}
\section{Second appendix}
\end{document}

But placing the letter in front of the Appendix name and I can't place it as the end. It would be great.

2 Answers 2

1

The following seems to be what you're after:

enter image description here

\documentclass{report}

\begin{document}

\tableofcontents

\chapter{A chapter}
\section{A section}
\subsection{A subsection}

\section*{Appendices}
\addcontentsline{toc}{section}{\bfseries Appendices}
\renewcommand{\thesubsection}{\arabic{subsection}}
\setcounter{subsection}{0}% Restart subsection numbering

\subsection{First appendix}
\subsection{Second appendix}

\end{document}

If you're using hyperref, more work needs to be done to accommodate for the referencing.

If you have more document content following the \chapter that contains your appendices, then you may have to restore the \subsection numbering. You can add

\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}

before that content.

0

A more general solution, reducing the \addcontentsline stuff and hyperref subtleties consists in using the appendix package and its subappendices environment:

\documentclass[a4paper,10pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[title,titletoc]{appendix}
\usepackage{lipsum}
\usepackage{hyperref}
\begin{document}
\tableofcontents

\chapter{Foo}
\section{Bar}
\lipsum[1]
\subsection{foo}  
\lipsum[2]

\section*{Appendices}
\addcontentsline{toc}{section}{Appendices}
\phantomsection
\begin{subappendices}
\setcounter{subsection}{0}
\renewcommand\thesubsection{\Alph{subsection}}
\subsection{Fisrt app}
\lipsum[3]
\subsection{second app}
\lipsum[4]
\end{subappendices}

\chapter{Foobar}
\section{bar2}
\subsection{foo2}  
\lipsum[5]
\end{document}

and expected result like: enter image description here

2
  • @Kola B. @Werner I have simplified and improve my former answer to show more clearly the power of the suggested package and the simplicity to make it working with hyperref. `Moreover \renewcommand{\thesubsection} and \setcounter{subsection}{0} are inside a group, making unneeded to undo these changes.
    – Jhor
    Aug 22, 2018 at 19:33
  • If you /really/ want 'Appendix A' instead of 'A Some title' , you’ll loose some important role of a title, and enter into trouble in the table of contents. An alternative w’d be using \usepackage[explicit]{titlesec} and adding\titleformat{\subsection}[hang]{\bfseries}{Appendix\ \thesubsection: #1}{0pt}{} just after \renewcommand\thesubsection{\Alph{subsection}}. By this way you could append a meaning full title after 'Appendix A'.
    – Jhor
    Aug 22, 2018 at 20:08

You must log in to answer this question.

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