[Tex/LaTex] Option clash for package color. \RequirePackage

colorincompatibility

I'm very new to LaTeX, and I'm having a problem which seems to originate from the following lines of code.

\RequirePackage[usenames]{color}
\RequirePackage{fancyhdr}
\RequirePackage{nomencl}
\RequirePackage{titlesec}
\RequirePackage{titletoc}
\RequirePackage{url}
\urlstyle{tt}

Option clash for package color. \RequirePackage error ocurred
at line \RequirePackage{fancyhdr}. Any idea?

Corresponding log output is this:

l.73 \RequirePackage
                    {fancyhdr}
The package color has already been loaded with options:
  []
There has now been an attempt to load it with options
  [usenames]
Adding the global options:
  ,usenames
to your \documentclass declaration may fix this.
Try typing  <return>  to proceed.

Best Answer

fancyhdr has nothing to do with the problem. Some package you load earlier already loads color without the usenames option.

The error message shows \RequirePackage, because this command scans for a possible optional argument; the complete syntax is

\RequirePackage[<options>]{<package>}[<YY>/<MM>/<DD>]

So when processing your command, LaTeX absorbs \RequirePackage[usenames]{color} and examines the next token in order to see if it is [. Since it isn't, it processes the call and stops because of the error; the error message shows the last token read by TeX.