[texhax] Changing \DeclareOption of some other packages
Uwe Lueck
uwe.lueck at web.de
Mon Jun 13 15:32:49 CEST 2011
"Vafa Khalighi" <vafa018 at gmail.com> wrote 13.06.2011 12:41:59:
> Sometimes package X loads package Y at the beginning of the document.
> Now I have a package that makes changes to package Y
> but since package X loads package Y at the beginning of the document,
> my changes to package Y is not applied. Something like the following:
>
> \usepackage{X} %which loads package Y at \begin{document}
> \usepackage{mypackage}
>
> If a user manually loads package Y before mypackage,
> changes to package Y are applied:
>
> \usepackage{X}
> \usepackage{Y}
> \usepackage{mypackage}
>
> However if in my package I add the following,
> changes to package Y are not applied:
>
> \@ifpackageloaded{X}{\RequirePackage{Y}}{}
>
> and the user loads packages as:
>
> \usepackage{X} %which loads package Y at \begin{document}
> \usepackage{mypackage}
>
> [i] Why my changes are not applied?
> [ii] how can I fix it?
> [iii] Is there a better approach for applying changes to a package
> even though that package is loaded at the beginning of the document?
First, concerning [iii] (and [ii]?), I recommend Alex Rozhenko's
afterpackage package
http://ctan.org/pkg/afterpackage
Then instead of your
> \@ifpackageloaded{X}{\RequirePackage{Y}}{}
try
\RequirePackage{afterpackage}
\AfterPackage{X}{\RequirePackage{Y}}
Note that the command doesn't have an "otherwise" argument
as \@ifpackageloaded has. \AfterPackage really postpones the change
until the other package is loaded, unless it has been loaded already.
For [i], I need some more minutes; I think one problem is that
it is not entirely true what you write, rather it depends ...
HTH -- Uwe.
More information about the texhax
mailing list