Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Possible duplicate of Replicate figure without inserting new entry in LoF –  percusse Dec 18 '11 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. –  Christian Lindig Dec 18 '11 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. –  Martin Scharrer Dec 19 '11 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. –  Martin Scharrer Dec 19 '11 at 8:51
    
@MartinScharrer After reading more carefully, I agree. Probably, I was too fast to skim through the question. –  percusse Dec 19 '11 at 15:34
add comment

migrated from stackoverflow.com Dec 18 '11 at 7:12

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 7 down vote accepted

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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