How can I have a command like \copypaste{ref-label}
such that it copy the corresponding environment to label \label{ref-label}
and paste it where the command \copypaste{ref-label}
is? or at least (if this is easier) two commands \copy{ref-label}
(placing inside of the environment) and \paste{ref-label}
(where we want to paste)?
I know that this commands may be useless but it is interesting and useful for me because sometimes I want to quote some lemmas, definitions,... from earlier chapters. Of course I can define new environments (new def, lem ,thm, ...) and set their counter to corresponding environment.
\label
-command is already defined and the concepts belonging to the\label..\ref
-mechanism are well established since decades and therefore should not be distorted. You'd need to give your command another name. In any case a problem is: When you have LaTeX (re)set whatsoever counters to former values, the likelihood is high that this will break thehyperref
package which forms names of destinations/referencing anchors from the current values and names of the corresponding counters while names of referencing anchors must be unique. Apart from that you could .. (see my next comment) – Ulrich Diez Oct 1 at 17:33\scantokens
to the expansion of that macro. This could even be done with an intermediate step via the .aux-file so that referencing before the thing occurs in the main text is possible. – Ulrich Diez Oct 1 at 17:33texlive 2019
but I havetexlive 2018
and your answer don't works for me. Also I tried to install v 2019 but failed. see this post. – C.F.G Dec 2 at 4:42