[Tex/LaTex] About numbering of figures and tables in appendix {elsarticle.cls}

appendiceselsarticlefloatsnumbering

When I am using elsarticle.cls to write papers, I always meet the following problem. If I already have one picture (table) in main text and then I put another picture (table) in appendix, the numbering of the picture (table) in appendix is not Figure A.1 (Table A.1) but Figure A.2 (Table A.2).

I tried to modify the elsarticle.cls by adding

\renewcommand\appendix{\par
  \setcounter{section}{0}%
  \setcounter{subsection}{0}%
  \setcounter{equation}{0}
  \setcounter{figure}{0}
  \setcounter{table}{0}
  ....

But I failed, always encountering warnings and errors.

Here is the test code:

\documentclass[preprint,12pt]{elsarticle}
\begin{document}
\section{Test}
\begin{table}[h]
  \caption{Test}\label{Tab_1}
  \centering{}
  \begin{tabular}{c|c}
  \hline
  $E(\mathrm{Mpa})$ & $\nu$\\
  \hline
  $6.8\times10^4$ & 0.21\\
  \hline
  \end{tabular}
\end{table}
\appendix
\section{Test}
\begin{table}[h]
  \caption{Test}\label{Tab_2}
  \centering{}
  \begin{tabular}{c|c}
  \hline
  $E(\mathrm{Mpa})$ & $\nu$\\
  \hline
  $6.8\times10^4$ & 0.21\\
  \hline
  \end{tabular}
\end{table}
\end{document}

If we put picture we meet also the same problem.I do not know why this happen. Does mean that in appendix we can not put any table or figure? Can anyone help me out?

Best Answer

A copy and paste from elsarticle.cls

\makeatletter
\renewcommand\appendix{\par
  \setcounter{section}{0}%
  \setcounter{subsection}{0}%
  \setcounter{equation}{0}%
  \setcounter{table}{0}%------------ << add
  \setcounter{figure}{0}%----------- << add
  \gdef\theequation{\@Alph\c@section.\arabic{equation}}%
  \gdef\thefigure{\@Alph\c@section.\arabic{figure}}%
  \gdef\thetable{\@Alph\c@section.\arabic{table}}%
  \gdef\thesection{\appendixname\@Alph\c@section}%
  \@addtoreset{equation}{section}%
  \@addtoreset{table}{section}%----- << add
  \@addtoreset{figure}{section}%---- << add
}
\makeatother