32

How can I add an appendix with two or 3 sections after each chapter in a book?

  • 1
    One 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. Segletes Jun 23 '13 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_gr Jun 23 '13 at 21:09
46

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:

enter image description here

An image of the first page of appendices for one of the chapters:

enter image description here

  • why we are using \lipsum[4]? – rainman Mar 8 '14 at 9:06
  • 1
    @Ome to easily generate filling text. – Gonzalo Medina Mar 8 '14 at 11:01
  • 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/… – Fiztban Jul 7 '14 at 15:28
7

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}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.