[Tex/LaTex] How to end appendix

appendicesnumberingsectioning

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.

Best Answer

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.

enter image description here

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