[OS X TeX] ifemptyelse

Peder Axensten peder at axensten.se
Sun Dec 19 01:24:32 CET 2004


I often need to check if some command is empty or not, so with the use 
of ifthen.sty I constructed
\newcommand{\ifemptyelse}[3]{%
	\savebox{\tempbox}{\parbox{50cm}{#1}}%
	\ifthenelse{\lengthtest{\wd\tempbox < 1pt}}{#2}{#3}%
}%

I works pretty well, except when the tested argument is a counter (or 
something else) that is changed.

For example
     \newcommand{\test}{One\footnote{Two}}
     \ifemptyelse{\test}{Is empty!}{Is '\test'!}
will result in "Is One2!" (should be "Is 'On1'!", of course) and one 
footnote.

Could anyone suggest definition of \ifemptyelse that works as expected?

By the way,
     \newcommand{\ifemptyelse}[3]{\ifthenelse{\equal{#1}{}}{#2}{#3}}
doesn't work at all with the example above...

/Peder
+46-90-786.7719 (work)
+46-90-32344 (home)

--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the macostex-archives mailing list