[texhax] intermediate output

Donald Arseneau wrote:
> burlen <bloring at unh.edu> writes:
>>> Hi I have a document where I have used \newcommand to define a number of
>> macros. My question is can I have latex make the macro substitutions and
>> stop, no further processing? I need to submit the document as latex source to
>> publisher who does not allow \newcommand macros. My macros have arguments so
>> simple search and replace won't work.
>> If your macros don't involve "programming", then a regular-expression
> replace can do the replacement.
>> If your macros do involve programming, then they have to be eliminated,
> regardless of substitution method. That is, your publisher won't allow
> that stuff.
I faced the same problem with my 'cleveref' package. To get around it, I
implemented a 'poorman' option that automatically writes a sed script
when the document is processed. When the original LaTeX source for a
document is passed through this script, it replaces all the
journal-unfriendly commands with their expansions, reducing them to
plain text and standard LaTeX.
If your macros don't involve programming, then I would just do regexp
replacement using your favourite out of sed, awk, perl or some other
language with good regexp support, as Donald recommends. If your macros
*do* involve programming, and this isn't just a one-off thing, the
cleveref 'poorman' option might give you some clues (the code's
documented using DocTeX, as usual).
However, I found it quite a chore to get it right, involving a lot of
fine-control of macro expansion order and various catcode manipulation
tricks, and I wouldn't be at all surprised if various parts of my ugly
code could be improved a lot by a true LaTeX guru. So I wouldn't
recommend going this route unless you're likely to reuse your macros
frequently.
HTH,
Toby