TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know I can redefine a control sequence to be empty or \relax, as in my example below. However, doing so doesn't prevent one from using that control sequence , because it is still defined.

To add some safeguards in my code, I'd like to wipe TeX's memory of a user-defined control sequence, so that, if I subsequently use that control sequence, I get the usual Undefined control sequence error. How can I do that?

\foo % no error
share|improve this question
\let\foo\undefined – Bordaigorl Nov 19 '13 at 14:52
So simple, yet I didn't know about it. Thanks. Let's wait to see if my question is a duplicate. Otherwise, you should post an answer. – Jubobs Nov 19 '13 at 14:54
related to (but not a duplicate of) tex.stackexchange.com/questions/12339/… – Jubobs Nov 19 '13 at 14:55
up vote 13 down vote accepted

The trick is to bind the macro to something which is not defined. Traditionally, the macro \undefined is left undefined (!) so you can simply do


If, for some (probably wrong) reason you or some package defines \undefined then this trick won't work.

In any case, if you later want to manually check whether \foo is defined or not, you can use LaTeX's \@ifundefined test which will detect whether \foo is undefined OR \relax.

share|improve this answer
Yes, there's no \undef primitive. There's \undef in etoolbox, but it relies on the same method: it does \let\foo\etb@undefined, trusting that \etb@undefined remains globally undefined. – egreg Nov 19 '13 at 18:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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