How can I add an appendix with two or 3 sections after each chapter in a book?
-
2One immediate question would be the nomenclature for the appendices. After chapter 2, for example, how would you like the appendices numbered? How should figures, tables, equations in these appendices be numbered?– Steven B. SegletesJun 23, 2013 at 20:45
-
Appendix 2A, 2B, the figures could be like figure 2A.1 and the equations 2B.1. Also I would like this appendix to be shown in the Table of contents (the title only).– Y_grJun 23, 2013 at 21:09
2 Answers
The subappendices
environment from the appendix
package could be useful here:
\documentclass{book}
\usepackage{appendix}
\usepackage{chngcntr}
\usepackage{etoolbox}
\usepackage{lipsum}
\AtBeginEnvironment{subappendices}{%
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}
\begin{document}
\tableofcontents
\chapter{Test Chapter One}
\section{A regular section}
\section{Another regular section}
\begin{subappendices}
\section{Some title for an appendix}
\lipsum[4]
\section{Some title for an appendix}
\lipsum[4]
\end{subappendices}
\chapter{Test Chapter Two}
\section{A regular section}
\section{Another regular section}
\begin{subappendices}
\section{Some title for an appendix}
\lipsum[4]
\section{Some title for an appendix}
\lipsum[4]
\section{Some title for an appendix}
\lipsum[4]
\end{subappendices}
\end{document}
An image of the resulting ToC:
An image of the first page of appendices for one of the chapters:
-
-
1
-
Can this method be applied to add appendices at the end of
Part
sections with multiple chapters within? I have opened a question thread for my specific case here and I would appreciate any input: tex.stackexchange.com/questions/188387/…– FiztbanJul 7, 2014 at 15:28 -
Nice answer. However, the theorems in the added appendices get numbered in the same way as in the usual text. Can you say how to arrange for the theorems to bear the name of the appendix? May 29, 2022 at 15:27
The (correct) answer given by @Gonzalo causes the numbering of tables and figures to reset in regular sections following an appendix. This is due to the \counterwithin
command that is called at the beginning of the subappendices
environment. To prevent this, one needs to revert to \counterwithout
at the end of the subappendices
environment:
% Start of subappendices environment
\AtBeginEnvironment{subappendices}{%
\chapter*{Appendices}
\addcontentsline{toc}{chapter}{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}
% End of subappendices environment
\AtEndEnvironment{subappendices}{%
\counterwithout{figure}{section}
\counterwithout{table}{section}
}