I want to process my class options so as to create a (potentially long) options list for package(s) I'm loading, e.g.
% set default package options here somehow
\DeclareOption{myvariant}{
% set a bunch of alternative options overriding the default
}
\RequirePackage[some kind of magic should go here]{mypackage}
Specifically, I thought maybe I should be using PassOptionsToClass, but then – how do I prevent the default action?
Right now I'm doing something else, and kind of ugly, which relies on my specific package of interest (geometry
) allowing doing everything with a command rather than a package option:
\newcommand{\iitcs@geometry{\geometry{key=val,key2=val2}}
\DeclareOption{myopt}{
\renewcommand{\iitcs@geometry{\geometry{key=val3,key3=val4}}
}
%...
\RequirePackage{geometry}
\iitcs@geometry
(edit) I'll emphasize that I'd like a solution for the case I have no choice but to provide the right package options, with no flexibility like with `geometry'.
Best Answer
You can use
\geometry
and options therein multiple times. So for this application I suggest something likeIn more general cases it may be more difficult, because options are executed in the order they are listed in the package, when it calls
\ProcessOptions
.So if
packageB.sty
declaresx
andnox
in this order (later using\ProcessOptions
, not\ProcessOptions*
) and you say inpackageA.sty
then
nox
will be executed last bypackageB
no matter if you callpackageA
with thex
option.So a more precise answer depends on "real world" situations.