# [texhax] Finding blank argument to macro

Matthew pruchek at gmail.com
Fri May 28 03:04:12 CEST 2010

Michael,

Many thanks!  I have tried it in my macro, and this snippet of code worked
like magic in a situation where a slew of other tests had failed.

-Matthew

-----Original Message-----
From: Michael Barr [mailto:barr at math.mcgill.ca]
Sent: Thursday, May 27, 2010 4:17 AM
To: pruchek at gmail.com
Cc: texhax at tug.org
Subject: Finding blank argument to macro

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