Monday, April 09, 2007

New appendix command in the article class

By default, the article class in LaTeX does not encourage users to write an appendix in an article. But users can still claim an appendix environment by typing:

\appendix

This will reset the counters for the section and subsection. However, (1) we have to manually type "Appendix" or "Appendices" for the section title; and (2) the counters for tables and figures still follow the numbering in the main text.

For the first point, there is the "appendix" package can deal with this.

# in the preamble
\usepackage{appendix}

# where you start your appendix
\appendix
\appendixpage

But this will give you an awkward large font for the section title for "Appendices." And the counter for tables and figures still following the main text counter.

The flexibility of TeX language allows us to write code to deal with aforementioned point 1 and point 2.

\renewcommand\appendix{\par
\setcounter{section}{0}%
\setcounter{subsection}{0}%
\setcounter{table}{0}
\setcounter{figure}{0}
\gdef\thetable{\Alph{table}}
\gdef\thefigure{\Alph{figure}}
\section*{Appendix}
\gdef\thesection{\Alph{section}}
\setcounter{section}{1}}


So now, put \appendix right before you write your appendix.

3 comments:

Thomas Bo Søndergaard Madsen said...

Nice rewrite of the appendix command

I added some regarding the numbering of the equations as well:
\renewcommand\appendix{\par
\setcounter{section}{0}%
\setcounter{subsection}{0}%
\setcounter{table}{0}
\setcounter{figure}{0}
\setcounter{equation}{0}
\gdef\thetable{\Alph{table}}
\gdef\thefigure{\Alph{figure}}
\gdef\theequation{\Alph{section}-\arabic{equation}}
\section*{Appendix}
\gdef\thesection{\Alph{section}}
\setcounter{section}{0}}

Term Papers said...

Good Article About "New appendix command in the article class"

Post by
Term Papers

kallis jatoi said...

Hey – great blog, just looking around some blogs, seems a really nice platform you are using. I’m currently using WordPress for a few of my blogs but looking to change one of them over to a platform similar to yours as a trial run. Anything in particular you would recommend about it? heike stopp