[texhax] How to test for existence of a macro?

D. R. Evans doc.evans at gmail.com
Sat Aug 29 02:14:48 CEST 2009

I couldn't find this in the TeXbook, but perhaps I was just looking in the
wrong place.

How should I test cleanly for the existence of a particular macro?

The use case is that I have been using pdfTeX for quite some time, and
hence using commands of the form \pdfxxx with impunity. Now that I'm trying
to use tex4ht, the first thing that happens is that it halts with an error
as soon as it hits the first of those commands.

(Actually, I guess I'm making an assumption that the \pdfxxx commands are
equivalent to macros, even though they're built-in.)

Anyway, what I want to do is stuff like replacing:
with something logically equivalent to:
  if (exists(\pdfoutput))
    do something else;

Presumably to do this one creates:
and then sets it to true or false depending on whether (say) \pdfoutput is
defined... but I don't know how to perform the test to see whether
\pdfoutput is defined in a way that doesn't cause an error if it's undefined.


Web:  http://www.sff.net/people/N7DR

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://tug.org/pipermail/texhax/attachments/20090828/0477b5f6/attachment.bin>

More information about the texhax mailing list