2

I would like to produce an article in which tables/figures are on separate pages at the end of the document (using endfloat), each being numbered sequentially from the main sections, and numbered with the appendix letter for those tables/figures that are in appendices.

An example is below, but the idea is to have all the floats at the end of the document going in the following order: Figure 1, Figure 2, Table 1, Table 2, Figure A.1, Figure A.2, Figure B.1, Figure B.2, Table A.1, Table A.2, Table B.1, Table B.2.

I am trying to modify an answer due to @egreg here: https://tex.stackexchange.com/a/218991/81204

See the following MWE:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[nofiglist,notablist]{endfloat}

\begin{document}

\section{Section one}

The main figure is Figure~\ref{Figure-1}, and the main table is Table~\ref{Table-1}. Supplemental material includes Figure~\ref{Figure-A1} and Table~\ref{Table-A1} in the first appendix, and Figure~\ref{Figure-B1} and Figure~\ref{Figure-B2} in the second appendix.

\begin{figure}
    \includegraphics{fig1}
\caption{Figure one} \label{Figure-1}
\end{figure}

\begin{table}
    \begin{tabular}{ll}
        Row 1 & 1\\
        Row 2 & 2\\
        Row 3 & 3\\
        Row 4 & 4\\
    \end{tabular}
\caption{Table one}\label{Table-1}
\end{table}

\appendix
\makeatletter
\renewcommand{\thepostfigure}{\Alph{section}.\arabic{postfigure}}%
\setcounter{postfigure}{0}%
\renewcommand{\theposttable}{\Alph{section}.\arabic{posttable}}%
\setcounter{posttable}{0}%
\efloat@iwrite{fff}{%
  \unexpanded{%
    \renewcommand{\thefigure}{\Alph{section}.\arabic{figure}}^^J%
    \setcounter{figure}{0}^^J%
    \renewcommand{\thetable}{\Alph{section}.\arabic{table}}^^J%
    \setcounter{table}{0}^^J%
  }%
}%
\makeatother

\section{Appendix one}

\begin{table}
    \begin{tabular}{ll}
        Row 1 & 1\\
        Row 2 & 2\\
        Row 3 & 3\\
        Row 4 & 4\\
    \end{tabular}
\caption{Table one in appendix A}\label{Table-A1}
\end{table}

\begin{figure}
    \includegraphics{fig1}
\caption{Figure one in appendix A} \label{Figure-A1}
\end{figure}

\section{Appendix two}

\begin{figure}
    \includegraphics{fig1}
\caption{Figure one in appendix B} \label{Figure-B1}
\end{figure}

\begin{figure}
    \includegraphics{fig2}
\caption{Figure two in appendix B} \label{Figure-B2}
\end{figure}

\renewcommand{\thefigure}{\arabic{figure}}
\renewcommand{\thetable}{\arabic{table}}
\end{document}

Compiling the above puts all the figures first, and then all the tables. Moreover, the figures in the main text are numbered sequentially but the figures are all labeled as if they are in the last appendix. I believe this has to do with the fact that endfloat is holding off on processing all the appendix figures at the end, when the running appendix is Appendix B. The tables are all labeled as if they are in the last appendix, and none of them are numbered as if they are in the main text.

Commenting out the figures, notice that when there are only tables the numbering of the floats in the back pages is 1, 2, etc.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[nofiglist,notablist]{endfloat}

\begin{document}

\section{Section one}

The main figure is Figure~\ref{Figure-1}, and the main table is Table~\ref{Table-1}. Supplemental material includes Figure~\ref{Figure-A1} and Table~\ref{Table-A1} in the first appendix, and Figure~\ref{Figure-B1} and Figure~\ref{Figure-B2} in the second appendix.

% \begin{figure}
%     \includegraphics{fig1}
% \caption{Figure one} \label{Figure-1}
% \end{figure}

\begin{table}
    \begin{tabular}{ll}
        Row 1 & 1\\
        Row 2 & 2\\
        Row 3 & 3\\
        Row 4 & 4\\
    \end{tabular}
\caption{Table one}\label{Table-1}
\end{table}

\appendix
\makeatletter
% \renewcommand{\thepostfigure}{\Alph{section}.\arabic{postfigure}}%
% \setcounter{postfigure}{0}%
\renewcommand{\theposttable}{\Alph{section}.\arabic{posttable}}%
\setcounter{posttable}{0}%
\efloat@iwrite{fff}{%
  \unexpanded{%
    % \renewcommand{\thefigure}{\Alph{section}.\arabic{figure}}^^J%
    % \setcounter{figure}{0}^^J%
    \renewcommand{\thetable}{\Alph{section}.\arabic{table}}^^J%
    \setcounter{table}{0}^^J%
  }%
}%
\makeatother

\section{Appendix one}

\begin{table}
    \begin{tabular}{ll}
        Row 1 & 1\\
        Row 2 & 2\\
        Row 3 & 3\\
        Row 4 & 4\\
    \end{tabular}
\caption{Table one in appendix A}\label{Table-A1}
\end{table}

% \begin{figure}
%     \includegraphics{fig1}
% \caption{Figure one in appendix A} \label{Figure-A1}
% \end{figure}

\section{Appendix two}

% \begin{figure}
%     \includegraphics{fig1}
% \caption{Figure one in appendix B} \label{Figure-B1}
% \end{figure}

% \begin{figure}
%     \includegraphics{fig2}
% \caption{Figure two in appendix B} \label{Figure-B2}
% \end{figure}

% \renewcommand{\thefigure}{\arabic{figure}}
\renewcommand{\thetable}{\arabic{table}}
\end{document}

However, when commenting out the tables, the numbering of the floats in the back pages is 1, B.1, B.2, B.3, etc. In other words, the numbering does restart but it is labeling all of the appendix figures as if they are in the last appendix.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[nofiglist,notablist]{endfloat}

\begin{document}

\section{Section one}

The main figure is Figure~\ref{Figure-1}, and the main table is Table~\ref{Table-1}. Supplemental material includes Figure~\ref{Figure-A1} and Table~\ref{Table-A1} in the first appendix, and Figure~\ref{Figure-B1} and Figure~\ref{Figure-B2} in the second appendix.

\begin{figure}
    \includegraphics{fig1}
\caption{Figure one} \label{Figure-1}
\end{figure}

% \begin{table}
%     \begin{tabular}{ll}
%         Row 1 & 1\\
%         Row 2 & 2\\
%         Row 3 & 3\\
%         Row 4 & 4\\
%     \end{tabular}
% \caption{Table one}\label{Table-1}
% \end{table}

\appendix
\makeatletter
\renewcommand{\thepostfigure}{\Alph{section}.\arabic{postfigure}}%
\setcounter{postfigure}{0}%
% \renewcommand{\theposttable}{\Alph{section}.\arabic{posttable}}%
% \setcounter{posttable}{0}%
\efloat@iwrite{fff}{%
  \unexpanded{%
    \renewcommand{\thefigure}{\Alph{section}.\arabic{figure}}^^J%
    \setcounter{figure}{0}^^J%
    % \renewcommand{\thetable}{\Alph{section}.\arabic{table}}^^J%
    % \setcounter{table}{0}^^J%
  }%
}%
\makeatother

\section{Appendix one}

% \begin{table}
%     \begin{tabular}{ll}
%         Row 1 & 1\\
%         Row 2 & 2\\
%         Row 3 & 3\\
%         Row 4 & 4\\
%     \end{tabular}
% \caption{Table one in appendix A}\label{Table-A1}
% \end{table}

\begin{figure}
    \includegraphics{fig1}
\caption{Figure one in appendix A} \label{Figure-A1}
\end{figure}

\section{Appendix two}

\begin{figure}
    \includegraphics{fig1}
\caption{Figure one in appendix B} \label{Figure-B1}
\end{figure}

\begin{figure}
    \includegraphics{fig2}
\caption{Figure two in appendix B} \label{Figure-B2}
\end{figure}

\renewcommand{\thefigure}{\arabic{figure}}
% \renewcommand{\thetable}{\arabic{table}}
\end{document}

I am confused about the asymmetry between tables and figures here, and would like to try to get the ordering I mentioned above. Another thing I noticed is that the labels in the text "Table A.1 about here." are using the correct appendix name (which I think is being handled by the postfigure/posttable part), even though the table/figure itself has a different name. In the examples above, I quote the actual names of the tables/figures in the back pages (rather than from the labels in the text). Any suggestions about these issues would be greatly appreciated.

2

You have to repeat the resetting at every \section in the appendix.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[nofiglist,notablist]{endfloat}
\usepackage{etoolbox}

\begin{document}

\section{Section one}

The main figure is Figure~\ref{Figure-1}, and the main table is Table~\ref{Table-1}. Supplemental material 
includes Figure~\ref{Figure-A1} and Table~\ref{Table-A1} in the first appendix, and Figure~\ref{Figure-B1} 
and Figure~\ref{Figure-B2} in the second appendix.

\begin{figure}
    \includegraphics{fig1}
\caption{Figure one} \label{Figure-1}
\end{figure}

\begin{table}
    \begin{tabular}{ll}
        Row 1 & 1\\
        Row 2 & 2\\
        Row 3 & 3\\
        Row 4 & 4\\
    \end{tabular}
\caption{Table one}\label{Table-1}
\end{table}

\appendix

\makeatletter
\renewcommand{\thepostfigure}{\Alph{section}.\arabic{postfigure}}
\setcounter{postfigure}{0}
\renewcommand{\theposttable}{\Alph{section}.\arabic{posttable}}
\setcounter{posttable}{0}
\efloat@iwrite{fff}{%
  \unexpanded{%
    \setcounter{section}{0}^^J%
    \renewcommand{\thefigure}{\Alph{section}.\arabic{figure}}^^J%
    \setcounter{figure}{0}^^J%
  }%
}
\efloat@iwrite{ttt}{%
  \unexpanded{%
    \setcounter{section}{0}^^J%
    \renewcommand{\thetable}{\Alph{section}.\arabic{table}}^^J%
    \setcounter{table}{0}^^J%
  }%
}
\preto{\section}{%
  \efloat@iwrite{fff}{%
    \unexpanded{%
      \stepcounter{section}^^J%
      \renewcommand{\thefigure}{\Alph{section}.\arabic{figure}}^^J%
      \setcounter{figure}{0}^^J%
    }%
  }%
  \efloat@iwrite{ttt}{%
    \unexpanded{%
      \stepcounter{section}^^J%
      \renewcommand{\thetable}{\Alph{section}.\arabic{table}}^^J%
      \setcounter{table}{0}^^J%
    }%
  }%
  \setcounter{posttable}{0}\setcounter{postfigure}{0}%
}
\makeatother

\section{Appendix one}

\begin{table}
    \begin{tabular}{ll}
        Row 1 & 1\\
        Row 2 & 2\\
        Row 3 & 3\\
        Row 4 & 4\\
    \end{tabular}
\caption{Table one in appendix A}\label{Table-A1}
\end{table}

\begin{figure}
    \includegraphics{fig1}
\caption{Figure one in appendix A} \label{Figure-A1}
\end{figure}

\section{Appendix two}

\begin{figure}
    \includegraphics{fig1}
\caption{Figure one in appendix B} \label{Figure-B1}
\end{figure}

\begin{figure}
    \includegraphics{fig2}
\caption{Figure two in appendix B} \label{Figure-B2}
\end{figure}

\renewcommand{\thefigure}{\arabic{figure}}
\renewcommand{\thetable}{\arabic{table}}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.