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

Susan Dittmar SDittmar at eureca.de
Wed Feb 11 19:04:57 CET 2009

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}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%