In other words: Is it possible to scan the input stream of a .sty or .cls file (without using Perl) for \ProcessOptions\relax and nest some given code afterwords? (The filehook or etoolbox package dont provide such macros. Or am I missing something?)

And as a Remark: Is it ethically correct to use such a macro to patch a package or class? (When I thought about it, I came to the conclusion that it must be alright to do so in a world where \renewcommand does exist. But please let me know what you think about it.)

1 Answer 1


The normal way in TeX is not to scan ahead but simply to redefine the command.

  \typeout{my stuff here}}

Probably outputs my stuff here just after the somepackage package has processed its options, then puts things back so later package loading is unaffected.

Redefining LaTex internals has risks, but it is certainly possible.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .