# How to recall a figure without rewriting it

I'm writing a long document and sometimes I need to recall a figure and show it (not just a \ref in the document). Right now every time I need this I rewrite the LaTeX code for showing the figure. Is there a way to recall a figure without rewriting it?

-

Updated to avoid duplicating the caption and label information.

\documentclass{article}

\usepackage{graphics}

\makeatletter
\def\savefloat#1{%
\expandafter\def\expandafter\@endfloatbox\expandafter{%
\@endfloatbox
\global\setbox#1\copy\@currbox}}

% Stephan Lehmke's \leaders trick to stop multiple writes.
\def\usefloat#1{%

\makeatother

\newsavebox\myfloat

\begin{document}

aaaa

\begin{figure}

\fbox{\begin{tabular}{l}a\\b\\c\end{tabular}}
\caption{hmmm}
\end{figure}

aaaa

\begin{figure}

\fbox{\begin{tabular}{l}a\\b\\c\end{tabular}}
\caption{hoooo}\label{xx}
\savefloat\myfloat
\end{figure}

bbbb

it looked like this

\fbox{\scalebox{.25}{\usefloat\myfloat}}

\end{document}
-
You gotta recognize David's answers even before you get to the badge at the very end... – yo' Dec 11 '12 at 15:49

You could define an entire float as the argument of a command such as \repeatedfigure. In the MWE below, this command takes an argument, which is the label to be assigned to the figure; if no extra label is desired, just specify an empty argument, {}. Oh, and I've assigned the h! location specifier to the repeated float as I'm assuming that you will wish to place it in very specific locations. If you're OK with LaTeX's default decision rules for placing floats, just remove the [h!] directive.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[demo]{graphicx} % leave off demo option in real program
\usepackage{lipsum} % for filler text

\newcommand{\repeatedfigure}[1]{%
\begin{figure}[h!] %
\caption{Repeated caption} % replace with real caption text...
\label{#1}
\centering
\includegraphics{demo.jpg} % use real filename if available
\end{figure}}

\begin{document}
\lipsum[2]
\repeatedfigure{fig:repfig}
\lipsum[2]
\repeatedfigure{}
Here's a cross-reference to Figure~\ref{fig:repfig}.

\lipsum[2]
\repeatedfigure{}
\end{document}

Addendum: This setup assumes that you want each instance of the repeated figure to have its own caption and entry in the List of Figures. If that's not the case, you could define the \repeatedfigure macro as follows:

\newcommand{\repeatedfigure}[1]{%
\begin{minipage}{\textwidth}
\centering
\includegraphics{demo.jpg}
\end{minipage}}
-
I assume the figure will get a new number and a lof entry for every repeat... – Stephan Lehmke Dec 11 '12 at 17:07
@StephanLehmke - Good point. I've provided an addendum to show what might be done if no repeated captions and entries in the LoF are needed. – Mico Dec 11 '12 at 18:09

Just an alternatively solution to the other answers. I would create a "factory" macro to create commands for image and caption storage. Consider a graphic with the filename "amato":

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\def\imagefactory#1#2{%
\expandafter\def\csname#1\endcsname{%
\includegraphics{#1}%
}
\expandafter\def\csname#1fig\endcsname{%
\includegraphics{#1}%
\captionof{figure}{#2}
}
\expandafter\def\csname#1float\endcsname{%
\figure[htbp]
\centering
\includegraphics{#1}%
\caption{#2}
\endfigure
}
}

\begin{document}
\imagefactory{amato}{This is a caption.}

\amato
\amatofig
\amatofloat

\end{document}

The MWE creates three commands a) just to store and provide a shorthand to includegraphics, the second essentially is a "here macro + caption" and the last a proper float. Stick the macros to a list and you have an image DB. Depending to what you need you can re-adjust the macros to do what you want (including references avoiding duplicating references - as per Dave's brilliant solution etc).

-