[texhax] Changing \DeclareOption of some other packages

Heiko Oberdiek heiko.oberdiek at googlemail.com
Mon Jun 13 19:27:34 CEST 2011


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:
> >>
> >> \@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).

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.

> 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.
And I strongly vote against such a procedure. It messes up
too much in internals for my taste.

Yours sincerely
  Heiko Oberdiek


More information about the texhax mailing list