我想要撰写一篇文章,其中的表格/图形位于文档末尾的单独页面上(使用 endfloat),每个表格/图形都按主要部分顺序编号,并且附录中的表格/图形使用附录字母进行编号。
下面是一个例子,但其想法是让文档末尾的所有浮点数按以下顺序排列:图 1、图 2、表 1、表 2、图 A.1、图 A.2、图 B.1、图 B.2、表 A.1、表 A.2、表 B.1、表 B.2。
我正在尝试修改@egreg 的答案: https://tex.stackexchange.com/a/218991/81204
请参阅以下 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}
编译上述内容时,所有图表都放在首位,然后是所有表格。此外,正文中的图表按顺序编号,但所有图表都贴有标签,好像它们位于最后一个附录中。我认为这与 endfloat 推迟处理末尾的所有附录图表有关,而当前附录是附录 B。所有表格都贴有标签,好像它们位于最后一个附录中,而没有一个表格像在正文中一样进行编号。
注释掉图形,注意当只有表格时,后页浮点数的编号为 1、2 等。
\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}
但是,在注释表格时,后面几页的浮动数字的编号为 1、B.1、B.2、B.3 等。换句话说,编号确实重新开始,但它会标记所有附录图,就好像它们在最后一个附录中一样。
\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}
我对此处表格和图形之间的不对称感到困惑,并想尝试获得我上面提到的顺序。我注意到的另一件事是,文本“此处的表格 A.1”中的标签使用了正确的附录名称(我认为这是由后图/后表部分处理的),即使表格/图形本身具有不同的名称。在上面的示例中,我在后页中引用了表格/图形的实际名称(而不是文本中的标签)。任何有关这些问题的建议都将不胜感激。
答案1
您必须\section
在附录中的每个位置重复重置。
\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}