5

I need to restart figure numbering in the Appendix, so that figures are 1, 2, ..; then S1, S2, .... Unfortunately, I can't figure out how to have endfloat refer to the two groups of figures differently. What I would like to have happen is as in the following code (without 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}

... but uncommenting endfloat (and deleting temporary files) causes the text and list of figures to refer to S1 and S2 (instead of 1 and S1), and the [Figure X about here] to refer to 1 and 2.

5

The counter postfigure needs to also be reset, like so:

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

Output

enter image description here


enter image description here


enter image description here

|improve this answer|||||
3

The counter used for the numbering “in place” is called postfigure, so also this one should be changed.

Here's a solution that exploits \appendix. The instruction for changing the counter representation and resetting the counter is written in the .fff file, so it will enter into action when the actual typesetting of figures takes place.

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

For producing the picture, the page height has been artificially reduced.

enter image description here

UPDATE

Unfortunately, endfloat version 2.6 introduced a bug which will make it not work as expected, besides breaking the code above. The package changed \immediate\write into \immediate\protected@write{}, which is wrong because \immediate cannot work in this situation.

Updated code:

\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}
|improve this answer|||||
  • @karlkoeller's answer above is simpler and seems to work fine; I added some of your explanation to it. Thanks to both!! – petrelharp Dec 21 '14 at 22:22
  • @petrelharp I beg to differ. My solution doesn't require any strange code in the body of the document. If you want to restore the usual behavior, just comment out the patch to \appendix. – egreg Dec 21 '14 at 22:24
  • ah, I see! yes, I agree. I guess I called it simpler because it only used commands I already understood. – petrelharp Dec 23 '14 at 15:59
  • @egreg's code does not compile anymore. The first error is "Argument of \reserved@a has an extra }. \end{document}", but there are many more. I suspect that endfloat 2.6 introduced some breaking changes. Has anyone an idea how to fix this? – mho87 Aug 8 '18 at 16:18
  • Please look at the non-answer above. – Johannes_B Aug 8 '18 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.