
LaTeX: Options Conflict for a Package
- Transfer
Translating the “Option clash for package” page from the FAQ UK
Users' Group.
I just inserted a line in the document
\usepackage[draft]{foo}
and now
! LaTeX Error: Option clash for package foo.
(Конфликт опций для пакета foo)
It seems that not everything is as simple as it seemed at the beginning. If the error is caused by the following code
\usepackage[dvips]{graphics}
\usepackage[draft]{graphics}
it should definitely be rewritten as follows:
\usepackage[dvips,draft]{graphics}
What to do when the cause of the error is not so obvious (even if such downloads are spaced across several lines, they are easy to detect with the naked eye)? It may turn out that the package we are interested in has already been downloaded somewhere else. But where exactly? If you press the h key after an error message, you can see the list of options with which the package downloads [1] [2] were called. If the response message looks different, then you will have to use the tips from the article How to approach errors . The main thing to remember is that the process of downloading a package in the log is surrounded by brackets, so if the package is
graphics
loaded in the package foo
, the log will look something like this(/foo.sty ...
...
(/graphics.sty ...
...)
...
)
Please note that the brackets related to the package
graphics
are enclosed in brackets related to the package foo
. In the case of a class bar
, the message will be exactly the same, only the first line will show the path to the file bar.cls
. If the package of interest to us is loaded inside another package, then you can ask
\usepackage{foo}
\usepackage[draft]{graphics}
should write
\PassOptionsToPackage{draft}{graphics}
\usepackage{foo}
Team
\PassOptionsToPackage
asks\PassOptionsToPackage
shows that you can specify several options at once. The matter is somewhat complicated if the options need to be passed to the package, which is loaded in the document class. In this case, instead
\documentclass[...]{bar}
\usepackage[draft]{graphics}
you should insert the command
\PassOptionsToPackage
before the command \documentclass
:\PassOptionsToPackage{draft}{graphics}
\documentclass[...]{bar}
It might seem that we are stuck if a package
foo
or class loads a bar
package graphics
with an option that conflicts with the one we would like to specify. for instance
\PassOptionsToPackage{draft}{graphics}
while the package or class says
\usepackage[final]{graphics}
will lead to the fact that the option
final
will be installed after the options passed from the outside, and draft
will be simply discarded. In some cases, the package may display an error message (but graphics
not one of them, and the option draft
will be discarded without any diagnostics). In this case, you can edit the package / class yourself (in accordance with its license). It will also be useful to contact the author of the package, which may offer alternative methods of solving the problem [3] .
Translator Notes
- Error message exampleHidden text
%clash.tex \documentclass{article} \usepackage[dvips]{graphics} \usepackage[draft]{graphics} \begin{document} \end{document}
$ latex clash.tex
...
! LaTeX Error: Option clash for package graphics.
See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...
l.5
? h
The package graphics has already been loaded with options:
[dvips]
There has now been an attempt to load it with options
[draft]
Adding the global options:
dvips,draft
to your \documentclass declaration may fix this.
Try typing to proceed. - In my
TeXstudio
command is executedlatex -interaction=nonstopmode ...
, and similar results need to be searched in the "basement" in the sectionLog - Log File
. - On TeX.SX offer a more elegant solution: a command
\PreventPackageFromLoading
packetscrlfile
.