The LaTeX2e
kernel defines usepackage
to be exactly the same as RequirePackage
in the ltclass.dtx
.
\if@compatibility\else\let\usepackage\RequirePackage\fi
So the fact that you use RequirePackage
makes no difference and you still get an error. If the same package is requested more than
once, nothing happens, unless the package has been requested with options that
were not given the first time it was loaded, in which case an error is produced.
Once you get the error message:
! LaTeX Error: Option clash for package xcolor.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.17
type "h" (without the quotation marks, for help) in the output console and you get
? h
The package xcolor has already been loaded with options:
[]
There has now been an attempt to load it with options
[table]
Adding the global options:
,table
to your \documentclass declaration may fix this.
So, you get an explanation of the problem and a possible solution. Doing as advised you prevent the clash:
\documentclass[a4paper,oneside,article,table]{memoir}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[danish]{babel}
\usepackage{lmodern}
\usepackage{graphicx}
\graphicspath{{Figures/}}
\usepackage{fullpage}
\usepackage{modroman}
\usepackage{float}
\usepackage{caption}
\usepackage[numbers]{natbib}
\usepackage{url}
\usepackage{pgfplots}
\usepackage{mathtools}
\usepackage{xcolor}
\begin{document}
test
\end{document}
Now, the problem was that another package (pgfplots
, in this case) had already loaded the xcolor
package without options, so loading it after pgfplots
with the table
option produces the clash. One way to prevent the problem was already presented (using table
as class option); another solution is to load xcolor
with the table
option before pgfplots
:
\documentclass[a4paper,oneside,article]{memoir}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[danish]{babel}
\usepackage{lmodern}
\usepackage{graphicx}
\graphicspath{{Figures/}}
\usepackage{fullpage}
\usepackage{modroman}
\usepackage{float}
\usepackage{caption}
\usepackage[numbers]{natbib}
\usepackage{url}
\usepackage[table]{xcolor}
\usepackage{pgfplots}
\usepackage{mathtools}
\begin{document}
test
\end{document}
Best Answer
In an ideal world, the LaTeX message
Option clash for package …
simply indicates an error and, as such, should not be ignored, but entail appropriate measures. Nonetheless, I’ve made the experience that, in reality, there are situations where it is either harmless or even advantageous to circumvent this error. Versatile tools for this purpose are\PreventPackageFromLoading
and\ResetPreventPackageFromLoading
from thescrlfile
package. Minimal example: