0

I need to write something with elsarticle and use endfloat, like it's 1980 or something.

I also have an appendix. The appendix contains equations, figures and tables. Appendix tables, figures, equations should be labeled Figure A.1 ... Figure A.2 for appendix A.

The elsarticle 'endfloat' option does nothing, so I load the package.

** Updated **

Before, all the figures were named consistent with appendix, not main document. So I am saving the counter before appendix and restore it before end of document. I am also using \addtodelayedfloat to adjust the numbering. Appendix C has the table, and it is captioned table C1. Great. It also shows like that on the list of Tables. Great. However, here is the problem:

it says [Table 2 about here] not [Table 1C about here].

Not sure what to do here. Minimal example below.

\documentclass[endfloat,preprint,authoryear,12pt]{elsarticle}

\usepackage{amssymb}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{endfloat}

\journal{}

\begin{document}

\begin{frontmatter}
\begin{abstract}
test
\end{abstract}
\begin{keyword}
test
\end{keyword}
\end{frontmatter}

\newpage

\section{mysection1}

test test

\begin{figure}[h!]
    \centering
    \caption{test1 - this should only be called figure 1}\label{fig:fig2}
    \includegraphics[scale=.6]{test.png} 
\end{figure}


\section{mysection2}

test test test

\begin{table}[htbp]
    \centering
    \caption{Tab1 - this should only be called table 1}\label{tab:tab1}
    \vspace{.25em}
    \begin{tabular}{lr}
        \toprule
        A&B\\
        \midrule
        1&2\\
        1&2\\
        \bottomrule
    \end{tabular}
\end{table}


\newpage
\let\thetableSAVED\thetable
\let\thefigureSAVED\thefigure
\appendix
%\let\thefigure\thefigureSAVED
%\let\thetable\thetableSAVED

\section{my first appendix}

%reset counter for appendix-numbering
%\numberwithin{table}{section}
%\setcounter{table}{0}
%\numberwithin{figure}{section}
%\setcounter{figure}{0}
%\numberwithin{equation}{section}
%\setcounter{equation}{0}

%from https://tex.stackexchange.com/questions/566447/combining-the-endfloat-package-and-an-appendix-with-different-figure-numbering




\begin{equation}
    x \sim N(1,0)
\end{equation}

\section{my second appendix}
\addtodelayedfloat{figure}{\renewcommand{\thefigure}{B\arabic{figure}}%
    \setcounter{figure}{0}}

\begin{figure}[h!]
    \centering
    \caption{test2}
    \includegraphics[scale=.6]{test2.png} 
    \label{fig:fig2}
\end{figure}


\section{my third appendix}
\addtodelayedfloat{table}{\renewcommand{\thetable}{C\arabic{table}}%
    \setcounter{table}{0}}
\begin{table}[htbp]
    \centering
    \caption{Tab2}
    \vspace{.25em}
    \begin{tabular}{lr}
        \toprule
            A&B\\
        \midrule
            1&2\\
            1&2\\
        \bottomrule
    \end{tabular}
    \label{tab:tab2}
\end{table}

\let\thefigure\thefigureSAVED
\let\thetable\thetableSAVED

\end{document}
2
  • The list of figures and list of tables appear when using the commands \listoffigures and \listoftables. You must usually compile the document two times to get the correct page number Mar 2, 2021 at 18:18
  • Texstudio does that for me. The pages are correct. However, in the output 'Appendix' is written over the entries.
    – Inferrator
    Mar 2, 2021 at 18:37

1 Answer 1

0

I solved it myself, with a combination of:

  • \let\thetableSAVED\thetable (and restoring it at the end)
  • \renewcommand\thepostfigure{A.\arabic{postfig}}
  • \addtodelayedfloat{figure}{\renewcommand{\thefigure}{B\arabic{figure}}\setcounter{figure}{0}}

Additional counter resets might be necessary, depending on what you might have.

\documentclass[endfloat,preprint,authoryear,12pt]{elsarticle}

\usepackage{amssymb}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{endfloat}

\journal{}

\begin{document}

\begin{frontmatter}
\begin{abstract}
test
\end{abstract}
\begin{keyword}
test
\end{keyword}
\end{frontmatter}

\newpage

\section{mysection1}

test test

\begin{figure}[h!]
    \centering
    \caption{test1 - this should only be called figure 1}\label{fig:fig2}
%   \includegraphics[scale=.6]{test.png} 
\end{figure}


\section{mysection2}

test test test

\begin{table}[htbp]
    \centering
    \caption{Tab1 - this should only be called table 1}\label{tab:tab1}
    \vspace{.25em}
    \begin{tabular}{lr}
        \toprule
        A&B\\
        \midrule
        1&2\\
        1&2\\
        \bottomrule
    \end{tabular}
\end{table}


\newpage
\let\thetableSAVED\thetable
\let\thefigureSAVED\thefigure
\appendix

\renewcommand\thepostfigure{A.\arabic{postfig}}
\renewcommand\theposttable{B.\arabic{posttbl}}

\addtodelayedfloat{figure}{\renewcommand{\thefigure}{B\arabic{figure}}\setcounter{figure}{0}}
\addtodelayedfloat{table}{\renewcommand{\thetable}{C\arabic{table}}\setcounter{figure}{0}}

\section{my first appendix}

\begin{equation}
    x \sim N(1,0)
\end{equation}

\section{my second appendix}

this should say figure B.1 about here


\begin{figure}[h!]
    \centering
    \caption{test2}
%   \includegraphics[scale=.6]{test2.png} 
    \label{fig:fig2}
\end{figure}


\section{my third appendix}

this should say table c.1 about here


\begin{table}[htbp]
    \centering
    \caption{Tab2}
    \vspace{.25em}
    \begin{tabular}{lr}
        \toprule
            A&B\\
        \midrule
            1&2\\
            1&2\\
        \bottomrule
    \end{tabular}
    \label{tab:tab2}
\end{table}

\let\thefigure\thefigureSAVED
\let\thetable\thetableSAVED

\end{document}
1
  • You can accept own answer and by this tell to audience, that your question is solved!
    – Zarko
    Mar 23, 2023 at 6:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .