2

I reference the float in different chapters. To make it easier for the reader, I would like to repeat the whole float, so the reader does not need to flick back to the chapter where the float occurred first. How does one do that properly? Ideally, it should involve the float's label to determine which float should be repeated and should make it possible to give it a new label command.

This is not a duplicate to Using the same figure twice with no new number because neither do I want to repeat the same figure number nor does the answer solve the problem of repeating the content (image or table).

\documentclass{book}
\usepackage{float}
\usepackage{graphicx}
\usepackage{nameref}
\usepackage{refstyle}

\begin{document}

\chapter{One}

Consider \figref{MyImage}.

\begin{figure}
\includegraphics{example-image-a}
\caption{My Image\label{fig:MyImage}}
\end{figure}

\chapter{Two}

Consider again \figref{MyImageAgain}.

% Some command to repeat a figure with two arguments
% 1. its label, "fig:MyImage", so it is known what should be repeated
% 2. its new custom label command, "\label{fig:MyFigureAgain}"
% - repeats its content
% - sets its caption to \caption{\nameref{fig:MyImage} (repeated from page \pageref{fig:MyImage})}.
% - set its label by using "\label{fig:MyFigureAgain}"
% So it should produce something like
%
% \begin{figure}
% \includegraphics{example-image-a}
% \caption{\nameref{fig:MyImage} (repeated from page \pageref{fig:MyImage})\label{fig:MyImageAgain}}
% \end{figure}

\end{document}
  • I can't imagine a document with 1000 figures, all of them are the same. – user156344 Apr 11 at 8:06
  • @JouleV Why 1000? Just a couple of figures get repeated. Or am I missing something? – Daniel Apr 11 at 8:08
  • 3
    Possible duplicate of Using the same figure twice with no new number – Bananguin Apr 11 at 10:15
  • 1
    @Daniel With your more elaborate wording, I'd change my vote to make this question a duplicate of that question. – Bananguin Apr 13 at 21:09
  • 1
    @Daniel You are incredibly frustrating. Your question is almost word by word the same. The described problem is painstakingly similar. Werners answer provides a macro \reusefigure which takes two parameters: placement information (which is optional) and a label and it does automatically repeat the content. I have no idea what you are looking for. – Bananguin Apr 14 at 6:29
1

A hack but how about defining macros for the body of the figures (including the caption but without the label) and using those? You did say that you were only concerned about a couple of figures. Something along the lines (untested):

\newcommand{\figa}[1]{main contents of figure \caption{#1}}
\newcommand{\figb}[1]{contents of another figure \caption{#1}}
...
\begin{figure}
  \centering
  \figa{First caption}
  \label{figafirst}
\end{figure}
In figure \ref{figafirst} ...
...
\begin{figure}
  \centering
  \figa{Modified caption}
  \label{figanext}
\end{figure}
Figure \ref{figafirst} is repeated as \ref{figanext}.

% and so on
  • Creating a macro and reusing it in multiple figure-environments is precisely what the accepted answer of the possible duplicate. The OP states that this is only good to know, but no answer. – Bananguin Apr 12 at 7:01
  • @Bananguin But the OP wanted to be able to have different numberings. – Peter Wilson Apr 12 at 17:38
  • @Bananguin I have expanded my answer. – Peter Wilson Apr 12 at 17:51
  • Both answers to the referenced question show different variants: with numbering, without numbering, the same numbering, different numbering. it is all there. – Bananguin Apr 13 at 18:09
  • @Bananguin I answered the OP's question. He said that the referenced previous answer didn't work for him. If you want to complain contact not me but the OP. GUM. – Peter Wilson Apr 14 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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