Add an appendix in LaTeX (appendix)

Write \appendix once, before the first appendix. From there on \section (in article) or \chapter (in report and book) is numbered with the letters A, B, C.

Preamble

The snippets on this page need these lines before \begin{document}:

\usepackage{graphicx}

Appendix in an article

\appendix takes no argument and prints nothing. It resets the section counter and switches its format to capital letters. \ref to a label in the appendix prints the letter.

\section{Results}
The raw data is listed in appendix~\ref{app:data}.

\appendix
\section{Raw data}\label{app:data}
Text of appendix A.

\section{Proofs}
Text of appendix B.
Result
The compiled example

Open in the editor

Appendix with chapters

In report and book the chapters after \appendix are headed "Appendix A", "Appendix B" in place of "Chapter 1".

Complete document:

\documentclass{report}
\begin{document}
\chapter{Results}
Text of chapter 1.

\appendix
\chapter{Raw data}
Text of appendix A.
\end{document}
Result
Page 1 of the compiled examplePage 1
Page 2 of the compiled examplePage 2

Open in the editor

Number figures as A.1, A.2

In article the figure and table numbers continue in the appendix. \counterwithin{figure}{section} after \appendix restarts the figure counter in every appendix and puts the letter in front.

\appendix
\counterwithin{figure}{section}
\counterwithin{table}{section}
\section{Raw data}
\begin{figure}[h]
\centering
\includegraphics[width=4cm]{image.png}
\caption{This figure has the number A.1}
\end{figure}
Result
The compiled example

A heading and a contents entry for all appendices

The appendix package provides the appendices environment. The option toc adds the line "Appendices" to the table of contents, page prints that word as a heading before the first appendix, and titletoc writes "Appendix A" in place of "A" in the table of contents.

Complete document:

\documentclass{article}
\usepackage[toc, page, titletoc]{appendix}
\begin{document}
\tableofcontents
\section{Results}
Text of the section.

\begin{appendices}
\section{Raw data}
Text of appendix A.
\end{appendices}
\end{document}
Result
The compiled example

Open in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages