0

I came across this excellent TeX.SE answer, demonstrating the use of subappendices.

I have intentionally pasted the nice MWE developed by user Gonzalo Medina there as a starting point for my queries. This is so that there is parity with this approach and others using it may benefit. It is pasted as below (with minor modifications).

\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

Questions

  1. How can I customize the header of each chapter appendix to include the chapter number, e.g. Appendices changed to Appendix - Chapter 1 for the Chapter One appendix?
  2. How can I change the indentation of the Appendices header titles in the TOC. Specifically, so that the Appendix TOC title is aligned with the respective chapter TOC title, not the Chapter TOC number? More specifically, in the TOC, I would like the text Appendices to be left aligned with text Test Chapter One (so the letter A from Appendices, aligns with the T from Test Chapter One), and then similarly for Test Chapter Two etc..

Any help on these would be appreciated.

1 Answer 1

1

Using

\AtBeginEnvironment{subappendices}{%
    \chapter*{Appendix - Chapter~\thechapter}
    \addcontentsline{toc}{chapter}{\hspace{1.5em}Appendices  - Chapter~\thechapter}
    \counterwithin{figure}{section}
    \counterwithin{table}{section}
}

will get you

a

and

b

(the chapter number is "1" not "One")

3
  • Thanks - this is great. A follow up, how did you figure out the 1.5em? Is it just by trial and error, or can that be derived programatically to always perfectly align. I ask because I had to change my actual document to 1.3em using trial and error. Would be great to avoid this if possible, i.e., using 1.5em for my actual LaTeX doc did align Appendix title with the Chapter title as needed, but using 1.3em did. Nov 5, 2022 at 23:47
  • @user4687531 In the standard classes book and report the chapter number is typeset in a box 1.5em wide. The number is hard coded but it can be changed, for example with the tocloft package. So in your actual document it will depend on the packages that customize the ToC and how. Nov 6, 2022 at 13:28
  • thank you for the clarification. I'll look into that. I've marked the question as solved. Nov 6, 2022 at 14:08

You must log in to answer this question.

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