레이블이 있는 endfloat로 부동 번호 매기기 다시 시작

레이블이 있는 endfloat로 부동 번호 매기기 다시 시작

부록에서 그림 번호 매기기를 다시 시작하여 그림이 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

"in place" 번호 매기기에 사용되는 카운터를 이라고 부르 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}

관련 정보