5

Possible Duplicate:
Can I redefine a command to contain itself?

How can I redefine the same macro that uses the original macro?

\newcommand{\macro}{zzz}
\renewcommand{\macro}{xyz\macro}

(this results in an endless loop)

calling \macro should print xyzzzz. (I want to redefine some symbols)

0
8

Assuming that the macros don't have optional parameters you can use:

\newcommand{\macro}{zzz}
\let\OldMacro\macro
\renewcommand{\macro}{xyz\OldMacro}

If you wish to redefine a macro that has optional parameters, you have to use \LetLtxMacro from the letltxmacro package . A detailed description of \LetLtxMacro can be found at this question at closed square root symbol.

The MWE below yields:

enter image description here

\documentclass{article}

\newcommand{\macro}{zzz}
\let\OldMacro\macro
\renewcommand{\macro}{xyz\OldMacro}

\begin{document}
\verb|\OldMacro:| \OldMacro

\verb|\macro:| \macro
\end{document}
0

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