[Solved] elsarticle with appendix and endfloat – numbering wrong, list of figures misplaced

Inferrator Asks: elsarticle with appendix and endfloat – numbering wrong, list of figures misplaced
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.

Code:
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
letthetableSAVEDthetable
letthefigureSAVEDthefigure
appendix
%letthefigurethefigureSAVED
%letthetablethetableSAVED

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}{Barabic{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}{Carabic{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}

letthefigurethefigureSAVED
letthetablethetableSAVED

end{document}

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.