# Using a figure again in document

I have drawn a schematic geometry an I want to describe the results of simulations I did with several configuration. So in Section XY I describe the simulations I did with a case set-up using the parameter set A refering to Figure 23 that contains the sketch of the geometry.

Later in Section XZ I write about simulations on a case using parameter set B. In order to avoid referring to a Figure that is located 10 pages earlier in the document I want to repeat Figure 23.

So I have several questions:

• Should I use the same figure number? If I repeat equations I use \tag{\ref{}} to get the same equation number. How can I achieve this with Figures?
• Can I reuse the figure caption somehow by some latex magic in order to avoid code duplication?
• Is there a correct way to do this? Am I violating some rules of style for thesis writing with my intended solution? I am aware that having the Figure 23 at page 67 and at page 89 feels weird, but as it is the same Figure, it seems to me to be the honest solution.

I am aware of the questions

• Are you using hyperref? What about a \listoffigures? How is that supposed to handle your re-use of the figure? – Werner Jan 26 '15 at 21:39
• I wouldn't do that if I were you, stranger. :) It could be honest, but often members of the tribunal do not have an open mind to imaginative formats. The comment could be "you mistakenly put the same image twice". Any document should be clear, concise, complete and brief. Could be your thesis more clear, concise, complete or brief with a duplicated image? Doubtful. – Fran Jan 26 '15 at 22:18
• Can't you reference the same figure 23 with \vref{fig:23}at page 87 with varioref without putting the image twice as @Fran said. Also see Cross-reference packages: which to use, which conflict? – texenthusiast Jan 27 '15 at 4:21
• @Fran So, I should not enforce the same figure number. I want to show the figure again, for the reader to be able to link the parameters listed in a table to the geometric dimensions of the sketch of the geometry. – Dohn Joe Jan 27 '15 at 9:53
• @DohnJoe If you consider imperative show the figure again, my suggestion is mix / join /include the image in the table (or viceversa) in a new figure, table or another type of float, with a reference in the caption to the first figure, so it should be evident that you ask to the reader to look at the same image again for another reason. Moreover, this simplify your life at the time of make cross-references and lists of figures and tables, without without the need to show duplicate entries. – Fran Jan 27 '15 at 12:31

I would duplicate the figure contents, just using a new environment that does some setup which avoids problems:

\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}

% \begin{reusefigure}[<float spec>]{<ref>}
\newenvironment{reusefigure}[2][htbp]
\renewcommand{\theHfigure}{dupe-fig}% If you're using hyperref
\renewcommand{\thefigure}{\ref{#2}}% Figure counter is \ref
\renewcommand{\addcontentsline}[3]{}% Avoid placing figure in LoF
\begin{figure}[#1]}
{\end{figure}}

\begin{document}

We have Figures~\ref{fig:caption-a},~\ref{fig:caption-b} and~\ref{fig:caption-c}.

\begin{figure}[ht]
\centering\includegraphics[height=50pt]{example-image-a}
\caption{A figure caption}\label{fig:caption-a}
\end{figure}

\begin{reusefigure}[ht]{fig:caption-a}
\centering\includegraphics[height=50pt]{example-image-b}
\caption{A figure caption}\label{fig:caption-b}
\end{reusefigure}

\begin{figure}[ht]
\centering\includegraphics[height=50pt]{example-image-c}
\caption{Another figure}\label{fig:caption-c}
\end{figure}

\end{document}


The reusefigure environment takes two arguments. The first is optional and similar to the float specification of regular figure floats. The second is mandatory and takes the \label of the figure to be reused.

Appropriate settings are adjusted prior to re-using the figure, including settings that for use with hyperref. Entry into the LoF is avoided, since it's not necessary.

Here is an implementation that automates the process. A to-be-used-later figure is constructed using sourcefigure. Then, to reuse this figure, use \reusefigure[<float spec>]{<ref>} where you specify the <ref> used in the \label of sourcefigure:

\documentclass{article}
\usepackage{graphicx,environ}
\usepackage{hyperref}

\NewEnviron{sourcefigure}[1][htbp]{%
{\let\caption\relax\let\ref\relax
\renewcommand{\label}[1]{%
\gdef\sfname{sf:##1}}%
\setbox1=\hbox{\BODY}}% Capture \label
\expandafter\expandafter\expandafter\gdef\expandafter\csname\expandafter\sfname\expandafter\endcsname\expandafter{\BODY}% Capture entire figure
\expandafter\show\csname\sfname\endcsname%
\begin{figure}[#1]
\BODY
\end{figure}
}
\newcommand{\reusefigure}[2][htbp]{%
\renewcommand{\theHfigure}{dupe-fig}% If you're using hyperref
\renewcommand{\thefigure}{\ref{#2}}% Figure counter is \ref
\renewcommand{\addcontentsline}[3]{}% Avoid placing figure in LoF
\renewcommand{\label}[1]{}% Make \label inactive
\begin{figure}[#1] \csname sf:#2\endcsname \end{figure}}
}

\begin{document}

We have Figures~\ref{fig:caption-a} and~\ref{fig:caption-c}.

\begin{sourcefigure}[ht]
\centering\includegraphics[height=50pt]{example-image-a}
\caption{A figure caption}\label{fig:caption-a}
\end{sourcefigure}

\reusefigure[ht]{fig:caption-a}

\begin{figure}[ht]
\centering\includegraphics[height=50pt]{example-image-c}
\caption{Another figure}\label{fig:caption-c}
\end{figure}

\end{document}


The \label macro is disabled inside \reusefigure, so referencing the reused figure is not possible (but surely not needed).

• \global\expandafter\let\csname\sfname\endcsname\BODY is much shorter, isn't it? – egreg Jan 27 '15 at 11:42

If you run into problem with \newenvironment macro (needing \protect and \expandafter, etc.), you can try:

\begin{figure}
\centering
\includegraphics[height=50pt]{example-image-a}
\caption{Figure A, initial usage}
\label{fig:a}
\end{figure}

\begin{figure*}
\centering
\includegraphics[height=50pt]{example-image-a}
\caption*{Figure \ref{fig:A}: Figure A, later usage somewhere else}
\end{figure*}

\begin{figure}
\centering
\includegraphics[height=50pt]{example-image-b}
\caption{Figure B, showing that the second usage of figure A does not increase counter}
\label{fig:b}
\end{figure}

• Why do you switch from figure to figure*? That may cause problems in a twocolumn document. – TeXnician Aug 24 '17 at 15:34
• And by the way, this does not replicate the caption on code-level. It's a manual solution after all. – TeXnician Aug 24 '17 at 15:37
• Dear @TeXnician, Case 1, using figure environment, requiring at least two steps: 1. prevent \thefigure from increasing 2. manually referencing the initial usage. Case 2, using figure* environment manually referencing the initial usage in the caption. In both cases, we always have to manually refer to the original usage. – Nam Tran-Hoang Oct 24 '17 at 14:35