# [texhax] Changing \DeclareOption of some other packages

Uwe Lueck uwe.lueck at web.de
Mon Jun 13 22:28:46 CEST 2011

"Heiko Oberdiek" <heiko.oberdiek at googlemail.com> wrote 13.06.2011 19:27:34:
>On Mon, Jun 13, 2011 at 04:40:51PM +0200, Uwe Lueck wrote:
>> "Heiko Oberdiek" <heiko.oberdiek at googlemail.com> wrote 11.06.2011 16:59:14:
>> > On Sat, Jun 11, 2011 at 11:40:10PM +1000, Vafa Khalighi wrote:
>> >
>> >> Say a package has:
>> >>
>> >> \DeclareOption{rightcaption}{\def\right{right}}
>> >>
>> >> but in my package, I want to change that:
>> >>
>> >>
>> >> How can you do that?
>> >
>> > You can't. If the package is loaded then the package options are processed
>> > and will not be executed later anymore.
>>
>> You can (I bet).
>
> In general no. If the package is loaded, then LaTeX does not load
> the package again. It only checks if there are new options requested
> and reports an error in this case.

Agreed: my "you can" is wrong with \@ifpackageloaded.
The latter is "too late". I meant to say that you can modify
a package option *before* loading the package, by sending
the modifying code to the \ProcessOptions command in the
latter package:

>> Redefine \@onefilewithoptions so that it uses
>> the \ProcessOptions command of the target package
>> as a hook to redefine the option before the options are actually
>> processed (and that hook also ensures restoring
>> the normal \ProcessOptions).
>
> That can be done only *before* the package is loaded.

As above.

> And I strongly vote against such a procedure. It messes up
> too much in internals for my taste.

So it's a matter of taste, o.k. We have a mess with hooks anyway,
and/or with making LaTeX2e flexible. And here I just considered
the original question a matter of sports, anyway of exploring possibilities.

The stack I mentioned (not copied above) could be implemented
by replacing \@pushfilename/\@popfilename by something more general
that would be useful anyway for handling sets of private letters
differing between packages.

Cheers,

Uwe.