Reinicie a numeração flutuante com endfloat com rótulos

Reinicie a numeração flutuante com endfloat com rótulos

Preciso reiniciar a numeração das figuras no Apêndice, para que as figuras sejam 1, 2, ..; então S1, S2, .... Infelizmente, não consigo descobrir como fazer com que endfloat se refira aos dois grupos de figuras de maneira diferente. O que eu gostaria que acontecesse é como no código a seguir (sem 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}

... mas descomentar endfloat (e excluir arquivos temporários) faz com que o texto e a lista de figuras se refiram a S1 e S2 (em vez de 1 e S1) e se [Figure X about here]refiram a 1 e 2.

Responder1

O contador postfiguretambém precisa ser zerado, assim:

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

Saída

insira a descrição da imagem aqui


insira a descrição da imagem aqui


insira a descrição da imagem aqui

Responder2

O contador utilizado para a numeração “in place” chama-se postfigure, portanto também este deverá ser alterado.

Aqui está uma solução que explora o \appendix. A instrução para alterar a representação do contador e zerar o contador está escrita no .fffarquivo, portanto entrará em ação quando ocorrer a própria composição das figuras.

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

Para produzir a imagem, a altura da página foi reduzida artificialmente.

insira a descrição da imagem aqui

ATUALIZAR

Infelizmente, endfloata versão 2.6 introduziu um bug que fará com que não funcione conforme o esperado, além de quebrar o código acima. O pacote mudou \immediate\writepara \immediate\protected@write{}, o que está errado porque \immediatenão pode funcionar nesta situação.

Código atualizado:

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

informação relacionada