I've developed a package in which I want to define a command \power, but that name is taken by a command in the SIunits package (which my package uses). I initially named my command \powr but decided to try renaming the \power command in SIunits and use \power in my own package. The problem is that I've apparently missed something or done something incorrect because I can't get the intended result.
(Note that I don't want to use siunitx over SIunits at present, although I will migrate to it in the future.)
Here is a MWE which does NOT included all the packages my own package uses. My major problem is that \square doesn't work as after renaming \power and I simply don't understand why. \sisquare doesn't work either but I don't use it. What am I missing?
\documentclass{article}
\usepackage{letltxmacro}
\usepackage{SIunits}
\newcommand*{\m}{\ensuremath{\mathrm{m}}
\LetLtxMacro{\sipower}{\power}
\renewcommand{\power}[1]{\ensuremath{#1 \; \mathrm{J/s}}}
\LetLtxMacro{\sisquare}{\square}
\renewcommand*{\square}[1]{\mathrm{#1}^{2}}
\renewcommand*{\squared}{\ensuremath{^{\mathrm{2}}}}
\renewcommand*{\cubic}[1]{\sipower{#1}{3}}
\renewcommand*{\cubed}{\ensuremath{^{\mathrm{3}}}}
\renewcommand*{\fourth}[1]{\sipower{#1}{4}}
\renewcommand*{\reciprocal}[1]{\sipower{#1}{\SIminus1}}
\renewcommand*{\rp}{\ensuremath{^{\mathrm{\SIminus1}}}}
\renewcommand*{\rpsquare}[1]{\sipower{#1}{\SIminus2}}
\renewcommand*{\rpsquared}{\ensuremath{^{\mathrm{\SIminus2}}}}
\renewcommand*{\rpcubic}[1]{\sipower{#1}{\SIminus3}}
\renewcommand*{\rpcubed}{\ensuremath{^{\mathrm{\SIminus3}}}}
\renewcommand*{\rpfourth}[1]{\sipower{#1}{\SIminus4}}
\begin{document}
\sipower{\m}{2} \par
\power{3} \par
$\sisquare\m$ \par
\square\m \par
\m\squared \par
\cubic\m \par
\m\cubed \par
\fourth\m \par
\reciprocal\m \par
\m\rp \par
\rpsquare\m \par
\m\rpsquared \par
\rpcubic\m \par
\m\rpcubed \par
\rpfourth\m
\end{document}


\AtBeginDocumentand your re-defined macro gets re-set. You can do the same (\AtBeginDocument{\LetLtxMacro … \renewcommand* …}). If you provide a MWE and describe your goal (what macro should output what?), an answer will come soon … – Qrrbrbirlbel Dec 24 '12 at 6:04SIunits). I would have thought the examples make the intended output quite clear, but perhaps not. The answer is indeed to use\AtBeginDocumentaround my renames. I won't answer my own question so if you answer I'll accept it. – user19024 Dec 24 '12 at 16:17Win a MWE means that this is the minimal offending code (not necessarily compiling) But I can assure you that this is friendly bunch here but sometimes comments sound harsher when written down than intentions. – percusse Dec 24 '12 at 17:12