# [texhax] Finding blank argument to macro

Tue Jun 29 10:25:32 CEST 2010

Michael Barr wrote:
> 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
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
>
> Automated subscription management: http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org

try the etoolbox it has some very good tests for empty arguments and
many other nice features

--

/daleif