Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to draw some coloured circles, so I loaded tikz in my preamble. However, now xcolor is telling me that it has an "option clash". How should I fix this?

\documentclass{article}
\usepackage{tikz}
\usepackage[table]{xcolor}

\begin{document}
Hello world.
\end{document}

The error message is this:

! LaTeX Error: Option clash for package xcolor.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.4 

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.
Try typing  <return>  to proceed.
share|improve this question

2 Answers 2

up vote 29 down vote accepted

Load xcolor before tikz:

\usepackage[table]{xcolor}
\usepackage{tikz}

The problem is that pgf/tikz already loads xcolor so loading it again with a new package option triggers the error message.

Another option is to pass the table option to the class and not to the xcolor package. Then the packages can be loaded in any order:

\documentclass[table]{article}
\usepackage{xcolor}
\usepackage{tikz}

or

\documentclass[table]{article}
\usepackage{tikz}
\usepackage{xcolor}
share|improve this answer
    
thanks for the clarification! –  Ariel Apr 11 '12 at 0:39
    
@Gonzalo-Medina Can any options for any package be passed to the document class? –  Ariel Apr 11 '12 at 1:35
1  
@Ariel: no, not every option for every package can be passed as a class option; it depends on how the option was declared in the package. –  Gonzalo Medina Apr 11 '12 at 1:46
3  
@GonzaloMedina Every option passed to the class is "global", so that it's tried with every loaded package. If the package knows it, it's applied; otherwise it's ignored. A package doesn't distinguish between global and local options (those which are passed in \usepackage). However, it's not a good idea to indiscriminately pass package options as global options. In this case it may be a good solution. –  egreg Apr 11 '12 at 6:40
    
@egreg: yes, I know that; my comment was addressing cases like \documentclass[T1]{report} \usepackage{fontenc} in which the option will be ignored. –  Gonzalo Medina Apr 11 '12 at 16:19

Add \PassOptionsToPackage{table}{xcolor} before \documentclass[10pt]{article} and remove the line \usepackage[table]{xcolor}.

share|improve this answer
3  
That fixes the problem - what it is doing and why did I get this error? –  Ariel Apr 11 '12 at 0:08
3  
@Ariel: I’m relatively sure, that it would be sufficient to load xcolor after the documentclass, but before other packages, that load itself (x)color. And TikZ is, in fact, one of those, but it loads xcolor without the table option. –  Speravir Apr 11 '12 at 0:21
    
Ah - so the error is because xcolor is loaded twice? –  Ariel Apr 11 '12 at 0:23
    
I second Ariel's query for further elucidation :-) ! –  nutty about natty Jul 8 '13 at 7:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.