\PassOptionsToClass
& \PassOptionsToPackage
¶Synopses:
\PassOptionsToClass{options}{clsname} \PassOptionsToPackage{option}{pkgname}
Adds the options in the comma-separated list options to the
options used by any future \RequirePackage
or
\usepackage
command for the class clsname or the package
pkgname, respectively.
The reason for these commands is that although you may load a package
any number of times with no options, if you can specify options only
the first time you load the package. Loading a package with options
more than once will get you an error like Option clash for
package foo.
. LaTeX throws an error even if there is no conflict
between the options.
If your own code is bringing in a package twice then you can combine the calls; for example, replacing the two
\RequirePackage[landscape]{geometry} \RequirePackage[margins=1in]{geometry}
with the single command
\RequirePackage[landscape,margins=1in]{geometry}
However, suppose you are loading firstpkg and inside that
package it loads secondpkg, and you need secondpkg
to be
loaded with option draft
. Then before load the first package
you must tell LaTeX about the desired options for the second
package, like this:
\PassOptionsToPackage{draft}{secondpkg} \RequirePackage{firstpkg}
If firstpkg.sty
loads an option in conflict with what you want
then you may have to alter its source, or yours.
These commands are useful for general users as well as class and package
writers. For instance, suppose a user wants to load the graphicx
package with the option draft
and also wants to use a class
foo
that loads the graphicx
package, but without that
option. The user could start their LaTeX file with
\PassOptionsToPackage{draft}{graphicx} \documentclass{foo}
.