[texhax] Changing \DeclareOption of some other packages

Uwe Lueck uwe.lueck at web.de
Mon Jun 13 16:40:51 CEST 2011


"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:
>>
>> \@ifpackageloaded{...}{\DeclareOption{rightcaption}{\def\right{Left}}{}
>>
>> 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). 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).

Such a redefinition may need to include a stack to
ensure that the \ProcessOptions of the target package
as opposed to \ProcessOptions commands of packages
that the target package loads actually is affected.

Nothing's impossible!

Cheers,

    Uwe Lück.



More information about the texhax mailing list