0

I am currently writing a report using LaTeX. I would like to insert an "appendix chapter" after a chapter (and before the next one).

The typical form of the report is :

\documentclass[useAMS,usenatbib,11pt]{report}
\usepackage[toc,page]{appendix}
\usepackage{hyperref}


\begin{document}

\tableofcontents




\chapter{Chapter 1}

\section{Section 1.1}

\section{Section 1.2}



\renewcommand{\thesection}{\thechapter.\Alph{section}}
\chapter*{Appendix}
\label{app:app_chap_1}
\addcontentsline{toc}{chapter}{\nameref{app:app_chap_1}}


\section{Appendix 1.A}

\section{Appendix 1.B}

\section{Appendix 1.C}



\renewcommand{\thesection}{\thechapter.\arabic{section}}
\chapter{Chapter 2}

\section{Section 2.1}

\section{Section 2.2}


\end{document}

The \renewcommand in the code are used to use numbers for the main text's sections, and letters for the appendices' sections.

In this example, I only showed an appendix for chapter 1. However, in the real manuscript, chapter 2 also has an appendix, and so on.

This code has the caveat of having the appendix be associated with the section counter of the previous chapter. Therefore, in this case, Appendix starts with the display 1.C. This can be seen in the Table of Contents:

ToC

I would like to start the appendix with 1.A. However, if I reset the counter using

\setcounter{section}{1}

then the Table of Contents links to section 1.1 instead of appendix 1.A.

To sum up, I would like to obtain the same visual result as in the image I showed, but with the appendix starting at 1.A. Furthermore, the Table of Content should be linking to the correct associated sections.

I tried to look for a solution using a new counter, but I am struggling with the link in the Table of Contents.

1
  • for the links you must also redefine \theHsection to give something unique. Commented Jun 14, 2023 at 14:21

1 Answer 1

0

What you want is almost exactly what the appendices environment does. The only difference is that it expects appendices to use \chapter instead of \section. This can be fixed by redefining \thesection locally. Alas, \setthesection is not implemented.

\documentclass[useAMS,usenatbib,11pt]{report}
\usepackage[toc,page]{appendix}
\usepackage{hyperref}

\begin{document}
\tableofcontents

\chapter{Chapter 1}
\section{Section 1.1}
\section{Section 1.2}

\begin{appendices}
\renewcommand{\thesection}{\arabic{@ppsavesec}.\Alph{section}}

\section{Appendix 1.A}
\section{Appendix 1.B}
\section{Appendix 1.C}
\end{appendices}

\chapter{Chapter 2}

\section{Section 2.1}

\section{Section 2.2}

\end{document}

One can also use the subappendices environment. This handles \thesection correctly, but does not support the toc and page options.

\documentclass[useAMS,usenatbib,11pt]{report}
\usepackage[toc,page]{appendix}
\usepackage{hyperref}

\begin{document}
\tableofcontents

\chapter{Chapter 1}
\section{Section 1.1}
\section{Section 1.2}

\begin{subappendices}
\part*{\appendixpagename}
\addcontentsline{toc}{chapter}{\appendixtocname}

\section{Appendix 1.A}
\section{Appendix 1.B}
\section{Appendix 1.C}
\end{subappendices}

\chapter{Chapter 2}
\section{Section 2.1}
\section{Section 2.2}

\end{document}
1
  • This is exactly what I was looking for. I knew about the \appendix command, but not the \begin{appendices} one. Thank you very much! Commented Jun 14, 2023 at 16:06

You must log in to answer this question.

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