# Setcounter not working in appendix

I would like all my tables and figures in the Appendix to be prefaced by A and to reset the counter for tables and figures. I have searched this forum and have found examples to do this. However, when I follow the examples, it doesn't do as I would like. In particular, it does not reset the counter (i.e. it just continues after the last table in the text) AND it sets ALL tables and figures in the entire document to begin with "A", not just those in the appendix. Not sure if I have too many packages or need another. I would appreciate any help. Here is my MWE:

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{url}
\usepackage{morefloats}
\usepackage{setspace}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{listings}
\usepackage{array}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage[flushleft]{threeparttable}
\usepackage{subcaption}
\usepackage[nomarkers,nolists]{endfloat}
\DeclareDelayedFloatFlavor{sidewaysfigure}{figure}
\DeclareDelayedFloatFlavor{sidewaystable}{table}

\begin{document}

\begin{table}[htbp]
\centering
\caption{Table 1}
\begin{tabular}{r}
\toprule
test \\
\bottomrule
\end{tabular}%
\end{table}

\appendix

\setcounter{table}{0}
\setcounter{figure}{0}
\renewcommand*{\thetable}{A\arabic{table}}
\renewcommand*{\thefigure}{A\arabic{figure}}
\input{Appendix.tex}  %\file with the written appendix

\begin{table}[htbp]
\centering
\caption{Table 2}
\begin{tabular}{r}
\toprule
test \\
\bottomrule
\end{tabular}%
\end{table

\end{document}

• Hi Mico. I was trying to reformat it so it looks like it does in Latex so easier on eyes (found it!). – Lori Oct 10 '13 at 5:32
• The problem stems from your loading of \usepackage[nomarkers,nolists]{endfloat}. I can reproduce the problem with just that and the booktabs package loaded (which is needed because of how your tables are constructed). – jon Oct 10 '13 at 5:49

Based on your insight Jon that it's the endfloat package I've figured it out. I've set it that the tables and figures are treated normally within the appendix (not using the endfloat package). Here's my solution:

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{url}
\usepackage{morefloats}
\usepackage{setspace}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{listings}
\usepackage{array}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage[flushleft]{threeparttable}
\usepackage{subcaption}
\usepackage[nomarkers,nolists]{endfloat}
\DeclareDelayedFloatFlavor{sidewaysfigure}{figure}
\DeclareDelayedFloatFlavor{sidewaystable}{table}

\begin{document}

\begin{table}[htbp]
\centering
\caption{Table 1}
\begin{tabular}{r}
\toprule
test \\
\bottomrule
\end{tabular}%
\end{table}

\makeatletter
\efloat@restorefloats
\makeatother
\appendix

\renewcommand*{\thetable}{A\arabic{table}}
\renewcommand*{\thefigure}{A\arabic{figure}}
\input{Appendix.tex}  % File with Appendix

\begin{table}[htbp]
\centering
\caption{Table 2}
\begin{tabular}{r}
\toprule
test \\
\bottomrule
\end{tabular}%
\end{table}

\setcounter{figure}{0} % Start again
\renewcommand\thefigure{\arabic{figure}}
\setcounter{table}{0} % Start again
\renewcommand\thetable{\arabic{table}}

\end{document}