I have a report where it's required to have sections from another report both in the main body as well as in an appendix, and I'm including them by using the \input{some_section} command.

I'm referring to figures in text by using:


Which works fine, but I'm getting warnings because the labels are multiply defined, since they occur in two parts of the report.

Is it possible for me to still reference the same image (essentially) without hard-labeling (i.e. typing Figure 1 in stead of Figure~\ref{fig:something}) ?

  • 1
    do you mean you are inputting the files twice, or that labels in the input file clash with labels in the main one? Commented Oct 17, 2014 at 20:18
  • I'm inputting the files twice. Commented Oct 17, 2014 at 20:30

2 Answers 2


You can add a macro to all the labels in the inputted file and either reset it manually or use \thechapter (for example).



Equation \eqref{first.1} and equation \eqref{first.2} are copies.

\begin{equation}\label{first.\thechapter} a=b \end{equation}
This references the local equation \eqref{first.\thechapter}.

\begin{equation}\label{first.\thechapter} a=b \end{equation}
This references the local equation \eqref{first.\thechapter}.


Come to think of it, instead of making many changes to the inputted file, you could use


at the beginning and


at the end.


You probably mean that the \label commands should be processed only the first time the file is input.

Start the file to input with

\ifcsname thisfilehasbeeninput\endcsname
   \global\expandafter\let\csname thisfilehasbeeninput\endcsname\relax

and end it with

\ifcsname thisfilehasbeeninput\endcsname

Instead of thisfilehasbeeninput you might use the file name; the string should be unique for every file you need to input twice.

In case the file hasn't yet been input, a command will be defined and nothing else will be done. If the file has already been input, that command will be defined and the \label command will be turned into a no-op. At the end, the original meaning of \label is restored.

You must log in to answer this question.

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