I am trying to implement LaTeX at my company to avoid a lot of manual work and errors
A report contains the same section multiple times – with only several component “tags” varying. The tags could be e.g. Qn_11 in first section, Qn_12 in second section and so on. The body text does not change, so when the document is copied in Word, the tags must be changed manually.
In LaTeX I was happy to discover that the same file can be inputted multiple times. The corresponding “tag” can be redefined with \renewcommand{}{}. However, a problem occurs with cross references. Unsurprisingly the multiply-defined labels warning pops up.
I only need to refer “inside” each section, i.e. the specific inputted file. Is there a way of “resetting” the labels or something similar before each input, so they can be used over and over within the single inputted file? I consider turning the sections into chapters. The objects (figures, tables, equations) will then be numbered 1.x, the first time the file is inputted, 2.x the next time and so on. If something can be worked out Thank you in advance!
A sniplet of the main file:
\documentclass{memoir}
\usepackage{graphicx}
\pagestyle{empty}
\begin{document}
\setcounter{chapter}{1}
\newcommand{\MyTag}{Qn-11}
\input{fileex}
\renewcommand{\MyTag}{Qn-12}
\input{fileex}
\end{document}
A sniplet of the inputted file:
\section{Header}
The component setting is \MyTag. See figure \ref{fig:setting}.
\begin{figure}[htbp]
\includegraphics[width=3cm]{example-image-a}
\caption{Caption}
\label{fig:setting}
\end{figure}
And the result (with the cross reference issue highlighted):


\ref{\MyTag fig:setting}and\label{\MyTag fig:setting}in thefileex.texfile? – Nov 23 '19 at 19:22fileex, which is why I wrote it that way. You could also define new commands\Refand\Label,\newcommand{\Label}[1]{\label{\MyTag#1}} \newcommand{\Ref}[1]{\ref{\MyTag#1}}, and replace all\refand\labelby\Refand\Labelinfileex.tex. What is "best" depends a bit on what you want to do on the long run. – Nov 23 '19 at 19:38fancyref, whereas\ref{fig:setting\MyTag}, for instance, won't. (Obviously, not everyone usesfancyref, but it is easy to avoid the potential breakage.) – cfr Nov 23 '19 at 21:58memoirandfancyref. Of course, I could just have made a stupid mistake. – Nov 23 '19 at 22:49