UK TeX FAQ -- question label optionclash

### Option clash for package

So you’ve innocently added:

> `\``usepackage[draft]{graphics}`

to your document, and LaTeX responds with

>     ! LaTeX Error: Option clash for package graphics.

The error is a complaint about loading a package with options, more than once (LaTeX doesn’t actually examine what options there are: it complains because it can’t do anything with the multiple sets of options). You can load a package any number of times, with no options, and LaTeX will be happy, but you may only supply options when you first load the package.

So perhaps you weren’t entirely innocent — the error would have occurred on the second line of:

> `\``usepackage[dvips]{graphics}`
> `\``usepackage[draft]{graphics}`

which could quite reasonably (and indeed correctly) have been typed:

> `\``usepackage[dvips,draft]{graphics}`

But if you’ve not made that mistake (even with several lines separating the `\``usepackage` commands, it’s pretty easy to spot), the problem could arise from something else loading the package for you. How do you find the culprit? The "`h`" response to the error message tells you which options were loaded each time. Otherwise, it’s down to the log analysis games discussed in “How to approach errors”; the trick to remember is that that the process of loading each file is parenthesised in the log; so if package foo loads graphics, the log will contain something like:

>     (<path>/foo.sty ...
>     ...
>     (<path>/graphics.sty ...
>     ...)
>     ...
>     )

(the parentheses for graphics are completely enclosed in those for foo; the same is of course true if your class bar is the culprit, except that the line will start with the path to `bar.cls`).

If we’re dealing with a package that loads the package you are interested in, you need to ask LaTeX to slip in options when foo loads it. Instead of:

> `\``usepackage{foo}`
> `\``usepackage[draft]{graphics}`

you would write:

> `\``PassOptionsToPackage{draft}{graphics}`
> `\``usepackage{foo}`

The command `\``PassOptionsToPackage` tells LaTeX to behave as if its options were passed, when it finally loads a package. As you would expect from its name, `\``PassOptionsToPackage` can deal with a list of options, just as you would have in the the options brackets of `\``usepackage`.

More trickily, instead of:

> `\``documentclass[...]{bar}`
> `\``usepackage[draft]{graphics}`

you would write:

> `\``PassOptionsToPackage{draft}{graphics}`
> `\``documentclass[...]{bar}`

with `\``PassOptionsToPackage` before the `\``documentclass` command.

However, if the foo package or the bar class loads graphics with an option of its own that clashes with what you need in some way, you’re stymied. For example:

> `\``PassOptionsToPackage{draft}{graphics}`

where the package or class does:

> `\``usepackage[final]{graphics}`

sets `final` after it’s dealt with option you passed to it, so your `draft` will get forgotten. In extreme cases, the package might generate an error here (graphics doesn’t go in for that kind of thing, and there’s no indication that `draft` has been forgotten).

In such a case, you have to modify the package or class itself (subject to the terms of its licence). It may prove useful to contact the author: she may have a useful alternative to suggest.

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=optionclash