8

For a paper I'm working on they want to have an appendix with all the figures from the main text. That is, figures should be in the main text (for publication), but they should be repeated in an appendix (for easy reviewing). Is there any package that does this? If not, how would I go about renewing the figure environment to create such an appendix?

5
  • Possible duplicate of Replicate figure without inserting new entry in LoF
    – percusse
    Dec 18, 2011 at 7:20
  • 2
    I expect that every figure environment must be written to a file which is later read to create the appendix. The TeXbook uses this to compile answers to exercises in an appendix. Dec 18, 2011 at 7:38
  • @percusse: The questions are related, but I don't think the answer to the linked one is satisfying here. I more automated way is needed. Dec 19, 2011 at 8:47
  • 1
    The endfloat package will move all your figures to the end and can leave marker behind. It might be possible to modify it to keep the original figures as well. Another idea is that you compile the document twice, once with endfloat active and once without it. You could then use includepdf to include the last pages with the figures to the normal version. It's a little more work, but should do the trick. Dec 19, 2011 at 8:51
  • @MartinScharrer After reading more carefully, I agree. Probably, I was too fast to skim through the question.
    – percusse
    Dec 19, 2011 at 15:34

1 Answer 1

7

It's just a matter of gathering the figures during the document in a token register, to be delivered at the end. By changing the counter we ensure that the figures are renumbered in the correct way.

\documentclass[a4paper]{article}

\usepackage{environ}

\makeatletter

\let\@@figure\figure
\let\@@endfigure\endfigure
\let\figure\@undefined
\let\endfigure\@undefined

\newtoks\end@figuretoks

\NewEnviron{figure}[1][htp]{%
  \@@figure[#1]\BODY\@@endfigure
  \global\end@figuretoks=\expandafter{\the\end@figuretoks\@@figure[p]}%
  \global\end@figuretoks=\expandafter{\the\expandafter\end@figuretoks\BODY\@@endfigure}%
  }

\newcounter{Endfigure}
\AtEndDocument{\clearpage\let\c@figure\c@Endfigure\the\end@figuretoks}
\makeatother

\usepackage{lipsum}

\begin{document}

\title{A document}
\author{A. N. Author}

\maketitle

\lipsum[1]

\begin{figure}[t]
\centering
1abc
\caption{def}
\end{figure}

\lipsum[2-4]

\begin{figure}
\centering
2abc
\caption{def}
\end{figure}

\lipsum[2-4]

\begin{figure}
\centering
3abc
\caption{def}
\end{figure}

\lipsum[2-4]

\begin{figure}
\centering
4abc
\caption{def}
\end{figure}

\lipsum[2-4]

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .