1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<head>
<title>UK TeX FAQ -- question label optionclash</title>
</head><body>
<h3>Option clash for package</h3>
<p/>So you’ve innocently added:
<blockquote>
<code>\</code><code>usepackage[draft]{graphics}</code>
</blockquote><p>
to your document, and LaTeX responds with
<blockquote>
<pre>
! LaTeX Error: Option clash for package graphics.
</pre>
</blockquote><p>
<p/>The error is a complaint about loading a package
<em>with options</em>, 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.
<p/>So perhaps you weren’t entirely innocent — the error would have
occurred on the second line of:
<blockquote>
<code>\</code><code>usepackage[dvips]{graphics}</code><br>
<code>\</code><code>usepackage[draft]{graphics}</code>
</blockquote><p>
which could quite reasonably (and indeed correctly) have been typed:
<blockquote>
<code>\</code><code>usepackage[dvips,draft]{graphics}</code>
</blockquote><p>
<p/>But if you’ve not made that mistake (even with several lines
separating the <code>\</code><code>usepackage</code> 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 "<code>h</code>" response to the
error message tells you which options were loaded each time.
Otherwise, it’s down to the log analysis games discussed in
“<a href="FAQ-erroradvice.html">How to approach errors</a>”; the trick to remember
is that that the process of loading each file is parenthesised in the
log; so if package <i>foo</i> loads <i>graphics</i>, the log
will contain something like:
<blockquote>
<pre>
(<path>/foo.sty ...
...
(<path>/graphics.sty ...
...)
...
)
</pre>
</blockquote><p>
(the parentheses for <i>graphics</i> are completely enclosed in
those for <i>foo</i>; the same is of course true if your class
<i>bar</i> is the culprit, except that the line will start with the
path to <code>bar.cls</code>).
<p/>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
<i>foo</i> loads it. Instead of:
<blockquote>
<code>\</code><code>usepackage{foo}</code><br>
<code>\</code><code>usepackage[draft]{graphics}</code>
</blockquote><p>
you would write:
<blockquote>
<code>\</code><code>PassOptionsToPackage{draft}{graphics}</code><br>
<code>\</code><code>usepackage{foo}</code>
</blockquote><p>
The command <code>\</code><code>PassOptionsToPackage</code> tells LaTeX to behave as if
its options were passed, when it finally loads a package. As you would
expect from its name, <code>\</code><code>PassOptionsToPackage</code> can deal with a list
of options, just as you would have in the the options brackets of
<code>\</code><code>usepackage</code>.
<p/>More trickily, instead of:
<blockquote>
<code>\</code><code>documentclass[...]{bar}</code><br>
<code>\</code><code>usepackage[draft]{graphics}</code>
</blockquote><p>
you would write:
<blockquote>
<code>\</code><code>PassOptionsToPackage{draft}{graphics}</code><br>
<code>\</code><code>documentclass[...]{bar}</code>
</blockquote><p>
with <code>\</code><code>PassOptionsToPackage</code> <em>before</em> the <code>\</code><code>documentclass</code>
command.
<p/>However, if the <i>foo</i> package or the <i>bar</i> class loads
<i>graphics</i> with an option of its own that clashes with
what you need in some way, you’re stymied. For example:
<blockquote>
<code>\</code><code>PassOptionsToPackage{draft}{graphics}</code>
</blockquote><p>
where the package or class does:
<blockquote>
<code>\</code><code>usepackage[final]{graphics}</code>
</blockquote><p>
sets <code>final</code> <em>after</em> it’s dealt with option you passed to
it, so your <code>draft</code> will get forgotten. In extreme cases,
the package might generate an error here (<i>graphics</i> doesn’t
go in for that kind of thing, and there’s no indication that
<code>draft</code> has been forgotten).
<p/>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.
<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=optionclash">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=optionclash</a>
</body>
|