如何添加包含两个或三个部分的附录后一本书中的每个章节?
答案1
环境subappendices
来自appendix
包在这里可能有用:
\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}
生成的 ToC 的图像:
其中一章附录第一页的图片:
答案2
@Gonzalo 给出的(正确)答案导致附录后的常规部分中的表格和图形编号重置。这是由于在环境\counterwithin
开始时调用的命令subappendices
。为了防止这种情况,需要在环境\counterwithout
结束时恢复subappendices
:
% 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}
}