Take the 2-minute tour ×

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
    % 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:


(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'.

share|improve this question
add comment

1 Answer

You can use \geometry and options therein multiple times. So for this application I suggest something like


\geometry{paperwidth=12cm,paperheight=12cm} % default

In 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 declares x and nox in this order (later using \ProcessOptions, not \ProcessOptions*) and you say in packageA.sty



then nox will be executed last by packageB no matter if you call packageA with the x option.

So a more precise answer depends on "real world" situations.

share|improve this answer
Umm, won't the \AtEndOfPackage be executed before the \geometry command below? Or maybe I'm missing its semantics. Also, and more importantly, I'm interested in a general approach, so let's assume I have to load the package with the proper options rather than a command later on. Have edited my question to clarify that. –  einpoklum Oct 7 '11 at 16:20
No, \AtEndOfPackage code is executed when LaTeX ends reading the .sty file, just prior returning to read the calling file. \ProcessOptions will simply set the token list for \AtEndOfPackage. –  egreg Oct 7 '11 at 16:25
How will it know which sty to exacute after? Also, in your second example, won't nox be executed first rather than last, due to the \ExecuteOption{nox}? Finally, I'm more interested in one-option-to-many rather than one-option-to-one. –  einpoklum Oct 7 '11 at 19:40
add comment

Your Answer


