Rooting through the cls file in the link posted above, I tried to dissect the following block, which looked rather promising:
\newcommand\listofappendices{%
\@chapteronefalse
\if@arabic\relax\else\renewcommand{\thepage}{\roman{page}}\fi
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapteruaf*{\listappname
\@mkboth{\uppercase{\listappname}}%
{\uppercase{\listappname}}}%
\@chapteronetrue
%% get this in contents as a section
\addcontentsline{toc}{section}{\listappname}
\@starttoc{loa}%
\if@restonecol\twocolumn\fi
\newpage\renewcommand{\thepage}{\arabic{page}}}
Basically, I realized that this command was setting up the List of Appendices for me, all I needed was a way to automatically populate it, instead of manually adding entries to the loa file.
At the head of each Appendix:
\chapter*{This is the first appendix}
\addcontentsline{loa}{appendix}{This is the entry for the first appendix in the List of Appendices}
The \chapter* suppresses a TOC entry for the appendix, while the \addcontentsline adds the entry to the LOA file. To get the style to match, I added the following line to the end of the code block in the cls file:
\newcommand\l@appendix{\@dottedtocline{1}{1.5em}{2.3em}}
Works perfectly now, and I don't have to worry about manually creating the List of Appendices every time I build my document.
Usually, appendices are common \chapters
placed after the \appendix
command in your input file, and you can't have a chapter inside a section; you have to respect the hierarchy of sectioning commands. Follow this link to get more familiar with the sectioning commands.
In order to get headings such as "Appendix A", "Appendix B", etc. within a section, you could use the next level of depth of sectioning commands, i.e. subsections. Use the starred version to get an unnumbered subsection:
\subsection*{Appendix A}
However, in most classes--notable exceptions include amsart
; see Ryan Reich's comment below--this will not produce any entry in your ToC, even if you have set the depth of your ToC to subsection level, using \setcounter{tocdepth}{2}
(or higher).
You must add the entry for that unnumbered subsection "manually", using
\addcontentsline{toc}{subsection}{Appendix A}
In summary:
\documentclass{article}
\usepackage{lipsum} % dummy text
\setcounter{tocdepth}{2}
\begin{document}
\tableofcontents
\section{Foo}
\lipsum[1]
\subsection*{Appendix A}
\addcontentsline{toc}{subsection}{Appendix A}
\lipsum[2]
\subsection*{Appendix B}
\addcontentsline{toc}{subsection}{Appendix B}
\lipsum[3]
\end{document}
Best Answer
\appendix
is a declaration and not an environment.I'd say that
should solve your problem. The sections will be numbered
A.1
,A.2
and so on.