[texhax] Finding blank argument to macro

Michael Barr barr at math.mcgill.ca
Thu May 27 13:17:05 CEST 2010


Here is a fragment of a macro I use to find if an argument is empty:

     \setbox0\hbox{$#9$}%
    \ifdim \wd0=0pt%
    %%%%%%%% omitted what you do if arg empty
    \else
    %%%%%%%% omitted what you do if not
    \fi

It is based on commands supplied in the TeX engine and, therefore, 
completely valid in (nearly) every version of TeX, including LaTeX.  (The 
reason for the (nearly) is that AMSTeX insists on killing certain 
primitive commands, but standard LaTeX doesn't.)  Incidentally, \box0 is a 
"scratch" box anyone can use, but don't expect to come back to it and find 
whatever you put in it unchanged.

Just a bit of a sermon.  There is no conflict between using LaTeX and 
using TeX.  There is some (very little actually) between PLAIN TeX and 
LaTeX and I have never understood the purists who insist on "pure LaTeX", 
whatever that might mean.

Michael Barr


More information about the texhax mailing list