[texhax] if condition: is macro body empty?
Philip G. Ratcliffe
philip.ratcliffe at uninsubria.it
Thu Feb 12 09:55:37 CET 2009
> 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.
> [snip]
This works too, doesn't need the "ifthen" package and shouldn't expand the
macro:
\newcommand{\buffer}{\relax}
\makeatletter
\newcommand{\fillbuffer}[1]{%
\if\buffer\relax
\g at addto@macro{\buffer}{#1}%
\else
\g at addto@macro{\buffer}{\newline #1}%
\fi
}
\makeatother
Cheers, Phil
More information about the texhax
mailing list