[texhax] controlling expansion

Neal H. Walfield neal at walfield.org
Thu Feb 28 12:22:51 CET 2013


I'm writing a macro that compares the value of a parameter.  I'm
currently using \ifx to do this as follows:

      not empty
  1: \dosomething{}
  2: \dosomething{1}
  3: \foo

This breaks if the caller uses \edef: \empty is expanded.  However, if
I protect \empty and \arg with a \noexpand, then bare uses (such as 1
and 2 in my above example) don't work:

  ! Use of \noexpand doesn't match its definition.
  \dosomething #1-> \def \noexpand \empty 
                                        {} \def \noexpand \arg {#1}
					\ifx \em...
  l.18 \edef\foo{\dosomething{}

What is the "right way" to compare argument values such that the macro
can (but need not) be used in an \edef context?



More information about the texhax mailing list