elsarticle 带有附录和 endfloat - 编号错误,图片列表放错位置

elsarticle 带有附录和 endfloat - 编号错误,图片列表放错位置

我需要用 elsarticle 写一些东西并使用 endfloat,比如 1980 或类似的。

我还有一个附录。附录包含方程式、图形和表格。附录表格、图形、方程式应标记为附录 A 的图 A.1 ... 图 A.2。

elsarticle 的“endfloat”选项没有任何作用,因此我加载了该包。

** 更新 **

之前,所有图表的命名都与附录一致,而不是主文档。因此,我在附录之前保存计数器,并在文档结束之前恢复它。我还使用 \addtodelayedfloat 来调整编号。附录 C 有表格,标题为表格 C1。很棒。它也显示在表格列表中。很棒。但是,问题在于:

它说的是[表 2 关于这里],而不是[表 1C 关于这里]。

不确定这里该做什么。下面是最小示例。

\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}

答案1

我自己解决了这个问题,方法是:

  • \let\thetableSAVED\thetable(最后恢复)
  • \renewcommand\thepostfigure{A.\arabic{postfig}}
  • \addtodelayedfloat{figure}{\renewcommand{\thefigure}{B\arabic{figure}}\setcounter{figure}{0}}

可能需要进行额外的计数器重置,具体取决于您所拥有的内容。

\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}

相关内容