[Tex/LaTex] Option clash for package xcolor

colorincompatibilitypackage-optionspgfplots

I'm writing a report, and have a rather large table in my appendix. I'd like to emphasize some specific values by coloring some single cells. I'm trying to do it with xcolor. But receiving the error:

! LaTeX Error: Option clash for package xcolor.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.17
The package xcolor has already been loaded with options:
[]
There has now been an attempt to load it with options
[table]

My preamble looks as follows

\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{pgfplots}
\usepackage{mathtools}
\usepackage[table]{xcolor}

And take out of my table

\begin{table}
 \centering
  \begin{tabular}{|c|c|c|}
       \hline
   \cellcolor{green!25}D & x & D/$L_0$ \\
       \hline
   65 & 2600 & 0,417\\
       \hline
   60 & 2400 & 0,385\\
  \end{tabular}
 \caption{Bestemmelse af bølgehøjde}
 \label{tab:Q1}
\end{table}

Read some other questions asking more or less the same. And the answer to them seems to be a "collision" between packages. I have no idea how to find the problem.
So my question is:

  1. Where is the "collision"?
  2. How on earth would I have found it without help ?

Best Answer

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}