Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question already has an answer here:

I would like to make a deep copy of macro that I don't have control of, because various packages might change it. So I want to take the current meaning of the macro, patching it, but without changing the original macro. Something along the lines of

\deepcopy\mylabel\label
\patchcmd{\mylabel}{\thepage}{\thepage+1}{}{}

How can I achieve that?

share|improve this question

marked as duplicate by mafp, Qrrbrbirlbel, tohecz, Joseph Wright Mar 2 '13 at 18:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
\let\mylabel\label; however, \LetLtxMacro from the letltxmacro package and \xpatchcmd from xpatch are required if the macro to copy and patch can have optional arguments or has been defined with \DeclareRobustCommand. –  egreg Mar 2 '13 at 17:04
    
\let\deepcopy=\let ;) However, \let is "exactly one layer deep". –  tohecz Mar 2 '13 at 17:04
    
@tohecz egreg Thanks. Seems I asked a stupid question. Shall I delete it? –  mafp Mar 2 '13 at 17:10
    
@mafp \let us close it as a duplicate of What is the difference between \let and \def? or What is the difference between \let and \edef? More information on letltxmacro can be found in When to use \LetLtxMacro? –  Qrrbrbirlbel Mar 2 '13 at 17:25
1  
@mafp: Definitely not a stupid question. If one does not know about \let it is difficult to search for it. Having a duplicate asked in a different way may help more people get to the solution, so best to not delete it. –  Peter Grill Mar 2 '13 at 18:28

Browse other questions tagged or ask your own question.