# [texhax] if condition: is macro body empty?

Wed Feb 11 19:13:02 CET 2009

Susan Dittmar wrote:
> Hi folk,
>
> for (pdf)latex I am looking for a way to check whether the body of a macro
> is empty or not. At the moment, I use a construct using \equal{}{<macro>},
> but I have the impression that during evaluation of this construct some
> ugly side effects occur. I am sure there must be a better way.
>
> Here's a short example (the final thing is much more complex, the \buffer
> being filled with parts of an \item list or with parts of a tabular):
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> \documentclass{article}
> \usepackage{ifthen}
> \newcommand{\buffer}{}
> \makeatletter
> % close to what I need:
> \newcommand{\fillbuffer}[1]{%
> 	\ifthenelse{\equal{\buffer}{}}%
> }
> \makeatother
> \begin{document}
>
> Filling the buffer may be called or not, and done here.
> \fillbuffer{First part.}
> \fillbuffer{Second part.}
>
> Now use the contents of this buffer:
>
> \buffer
>
> \end{document}
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>
>
> 	Susan
>

I've use ifmtarg in my last project, had to use some \expandafter
sometimes, but for my purpose it worked fine

--

/daleif