# How to end appendix?

Is there a way to end the \appendix?

Specifically, I have a file like this:

\documentclass{article}
\begin{document}
\section{one}
Should be section1
\section{two}
Should be section 2
\appendix
\section{a1}
Should be A

\section{b}
should be B

\section{three}
Should be 3

\end{document}


and I can't seem to get the appendix to "end" in any way. I'd rather not reset the section counter to a specific number manually because I might go back and add several sections above the appendix later.

The \appendix command is a one way switch. In article.cls it does:

\setcounter{section}{0}% Resets the section counter
\setcounter{subsection}{0}% and the subsection counter
\gdef\thesection{\@Alph\c@section}% and makes \thesection with Alph numbering


you cannot simply revert this because the section numbering is lost.

You can create a counter savesection to store the section number, then create an \unappendix command that reverts the changes done by \appendix.

Additionally I added a apdxsection counter to save the appendix numbering, so you can switch back and forth from normal sections to appendices.

\documentclass{article}

\makeatletter
\newcounter{savesection}
\newcounter{apdxsection}
\renewcommand\appendix{\par
\setcounter{savesection}{\value{section}}%
\setcounter{section}{\value{apdxsection}}%
\setcounter{subsection}{0}%
\gdef\thesection{\@Alph\c@section}}
\newcommand\unappendix{\par
\setcounter{apdxsection}{\value{section}}%
\setcounter{section}{\value{savesection}}%
\setcounter{subsection}{0}%
\gdef\thesection{\@arabic\c@section}}
\makeatother

\begin{document}
\section{one}
Should be section1
\section{two}
Should be section 2

\appendix

\section{a}
Should be A

\section{b}
should be B

\unappendix

\section{three}
Should be 3

\appendix

\section{c}
should be C

\end{document}

• Thanks. Calling it endappendix results in: ! LaTeX Error: Command \endappendix already defined. Or name \end... illegal, see p.192 of the manual. but calling it finishappendix works just fine. – Alex Jul 31 '18 at 18:49
• @Alex First I called it \unappendix, then I thought "\endappendix sounds better" and changed, but then I remembered about this and reverted. You could put these definitions in a \newenvironment and use \begin{appendix}...\end{appendix}, but I think that the group created could make some mess, so I preferred to leave as two separate switches. – Phelype Oleinik Jul 31 '18 at 18:53