In the following MWE I've used \renewcommand to redefine a command defined through \def:
\documentclass{article}
\def\mymacro{Hello}
\renewcommand{\mymacro}{Hello world}
\begin{document}
\mymacro
\end{document}
and it works fine, as far as I can see.
What I would like to know is:
- Are there cases in which it doesn't work?
- Is it a good practice or I should I use
\defto redefine commands defined through\def?
EDIT
I've already taken a look at What is the difference between \def and \newcommand?. What I mean is that sometimes I need to hack some commands defined through \def and I would like to know whether I'm allowed to do that with \renewcommand or not.
\defunless you need to. Use\(re)newcommandwhere possible. – Ian Thompson Nov 16 '13 at 09:16renewcommandis only a wrapper around\def. – Marco Daniel Nov 16 '13 at 10:17\defis "context sensitive", it can't be redefined with\renewcommand. but for a simple definition like the one you show,\renewcommandworks just fine, and is probably preferable. – barbara beeton Nov 16 '13 at 13:32\renewcommandrequires is 1) that the command already have a meaning, 2) that it is not\relax, and 3) that it doesn't start with\end. It doesn't care how the command acquired it's meaning. It could be via\def,\letor even\chardef,\countdef, etc. What @barbarabeeton is saying is that\renewcommandcan't always duplicate the argument syntax of the original command. – Dan Nov 16 '13 at 22:53