When I want some macro to (temporarily) do nothing, I normally write


But somebody asked me why I don't just do


and I realized I couldn't answer his question.

So, I have two questions:

  1. Can somebody give a practical example of when the two would be different;
  2. For the purpose of disabling a macro, which of the two is preferred?

Here's an example of how I normally use this:


2 Answers 2


When you


you are giving \foo an empty definition, but \foo still 'exists' using any of the tests used for this (such as \ifdefined or LaTeX's \@ifundefined). The same effect can be achieved by doing


which is very slightly more efficient as it points to an already-used memory location (not a worry nowadays). When \foo has such a definition, it is expandable, and so


will result in \baz being empty, as \foo expands to nothing at all.

On the other hand


makes \foo equal to the \relax primitive. That is a 'do nothing' operation, but importantly is not expandable. So in this case


leaves \baz with definition '\foo'. That can be useful: it's a way of temporarily preventing a macro from doing anything while retaining it's appearance in other code. On the other hand, sometimes you don't want that: it depends on the context. When \foo is equal to \relax, whether it is regarded as 'existing' by the various tests is more variable. TeX automatically creates control sequences equal to \relax in various cases, and so some tests will regard anything equal to \relax as 'not defined'.

So which is better depends on your use case.

  • Thanks for the explanation. I just added my use case to my question.
    – mtvec
    Mar 23, 2012 at 7:29

The first one lets \foo to point to \relax, whereas the second to an empty macro. (Provided no-one re-defined \relax or \empty.

\ifx\foo\relax True\fi
\ifx\foo\empty True \fi

For the purpose of undefining none is recommended, rather use


At any stage you can test via \meaning


will show \relax


As per revised question. To temporarily disable let the command to a relax within a group as shown:

{\let\foo\relax \foo}

Within the group the meaning of the command will be equal to \relax and do nothing. Outside the group it will have its value restored.

  • 1
    for undefining, \let\foo\relax is fine in plain TeX. Otherwise I agree.
    – mbork
    Mar 23, 2012 at 7:10
  • I'm sorry I meant "disabling" a macro instead of "undefining" it. I still want to be able to use it. I updated my question.
    – mtvec
    Mar 23, 2012 at 7:13
  • @job You mean like if condition X do nothing else do something else (see edit)?
    – yannisl
    Mar 23, 2012 at 7:17
  • I updated my question with an example of how I normally use this.
    – mtvec
    Mar 23, 2012 at 7:25
  • @Job In your context \relax is fine.
    – yannisl
    Mar 23, 2012 at 7:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .