
我需要重新開始附錄中的數字編號,讓數字為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}