![使用带标签的 endfloat 重新开始浮点编号](https://linux22.com/image/477064/%E4%BD%BF%E7%94%A8%E5%B8%A6%E6%A0%87%E7%AD%BE%E7%9A%84%20endfloat%20%E9%87%8D%E6%96%B0%E5%BC%80%E5%A7%8B%E6%B5%AE%E7%82%B9%E7%BC%96%E5%8F%B7.png)
我需要在附录中重新开始对图形进行编号,这样图形就为 1、2、..;然后是 S1、S2、....。不幸的是,我不知道如何让 endfloat 以不同的方式引用这两组图形。我希望发生的事情如下代码所示(没有 endfloat):
\documentclass{article}
\usepackage[draft]{graphicx}
% \usepackage{endfloat}
\begin{document}
As we see in figure \ref{fig1} (and also in supplemental figure \ref{figS1}) \ldots
\begin{figure}
\includegraphics{fig1}
\caption{ One. } \label{fig1}
\end{figure}
\clearpage
\renewcommand{\thefigure}{S\arabic{figure}}
\setcounter{figure}{0}
\begin{figure}
\includegraphics{figS1}
\caption{ Supplement, one. } \label{figS1}
\end{figure}
\end{document}
...但是取消注释 endfloat(并删除临时文件)会导致文本和图形列表引用 S1 和 S2(而不是 1 和 S1),并且[Figure X about here]
引用 1 和 2。
答案1
计数器postfigure
也需要重置,如下所示:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[nofiglist]{endfloat}
\begin{document}
\listoffigures
\clearpage
\section{Test}
As we see in figure \ref{fig1} (and also in supplemental figure \ref{figS1}) \ldots
\begin{figure}
\includegraphics{fig1}
\caption{ One. } \label{fig1}
\end{figure}
\processdelayedfloats
\clearpage
\appendix
\section{Appendix}
\renewcommand{\thefigure}{S\arabic{figure}}
\renewcommand{\thepostfigure}{S\arabic{postfigure}}
\setcounter{figure}{0}
\setcounter{postfigure}{0}
\begin{figure}
\includegraphics{figS1}
\caption{ Supplement, one. } \label{figS1}
\end{figure}
\processdelayedfloats
\end{document}
输出
答案2
用于“就地”编号的计数器称为postfigure
,因此这个也应该更改。
这是一个利用 的解决方案\appendix
。更改计数器表示和重置计数器的指令写在文件中.fff
,因此它将在实际排版图形时生效。
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{endfloat}
\usepackage{etoolbox}
\makeatletter
\appto{\appendix}{%
\renewcommand{\thepostfigure}{S\arabic{postfigure}}%
\setcounter{postfigure}{0}%
\efloat@iwrite{fff}{%
\unexpanded{%
\renewcommand{\thefigure}{S\arabic{figure}}^^J%
\setcounter{figure}{0}^^J%
}%
}%
}
\makeatother
\begin{document}
As we see in figure \ref{fig1} (and also in supplemental figure \ref{figS1}) \ldots
\begin{figure}
\includegraphics{fig1}
\caption{One.} \label{fig1}
\end{figure}
\clearpage % not necessary, just to make the figure go to the next page
\appendix
\begin{figure}
\includegraphics{figS1}
\caption{Supplement, one.} \label{figS1}
\end{figure}
\renewcommand{\thefigure}{\arabic{figure}}
\end{document}
为了制作图片,页面高度被人为地降低了。
更新
不幸的是,endfloat
2.6 版引入了一个错误,除了破坏上述代码外,还会导致它无法按预期工作。包更改\immediate\write
为\immediate\protected@write{}
,这是错误的,因为\immediate
在这种情况下无法工作。
更新的代码:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{endfloat}
\usepackage{etoolbox}
\makeatletter
% fix the wrong code in endfloat.sty
\@ifundefined{protected@iwrite}{%
\let\protected@iwrite\protected@write
\patchcmd{\protected@iwrite}{\write}{\immediate\write}{}{}%
\def\efloat@iwrite#1{\expandafter\protected@iwrite\csname efloat@post#1\endcsname{}}%
}{}
% double 'unexpansion' now is needed
\appto{\appendix}{%
\renewcommand{\thepostfigure}{S\arabic{postfigure}}%
\setcounter{postfigure}{0}%
\efloat@iwrite{fff}{%
\unexpanded{\unexpanded{%
\renewcommand{\thefigure}{S\arabic{figure}}^^J%
\setcounter{figure}{0}^^J%
}}%
}%
}
\makeatother
\begin{document}
As we see in figure \ref{fig1} (and also in supplemental figure \ref{figS1}) \ldots
\begin{figure}
\includegraphics{fig1}
\caption{One.} \label{fig1}
\end{figure}
\clearpage % not necessary, just to make the figure go to the next page
\appendix
\begin{figure}
\includegraphics{figS1}
\caption{Supplement, one.} \label{figS1}
\end{figure}
\renewcommand{\thefigure}{\arabic{figure}}
\end{document}