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 have these following packages defined in my preamble and once the file is ran, it creates an error of the following saying there is a clash within the package options. Packages are below:

\documentclass[addpoints,11pt]{exam}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{enumerate}
\usepackage{array}
\usepackage{amsthm}
\usepackage{cancel}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{upgreek}
\usepackage{calligra}
\usepackage{graphicx,graphics}
\usepackage[normalem]{ulem}
\usepackage[all]{xy}
\usepackage[dvipsnames]{xcolor}

\begin{document}
 .......    
\end{document}

Error Log

Is there a way to prevent and what is the actual root of the problem to persist?

share|improve this question
2  
tikz is the package which already loads xcolor –  Herbert Aug 14 '11 at 6:54
    
\PassOptionsToPackage{dvipsnames}{xcolor} as I alread wrote in my answer –  Herbert Aug 14 '11 at 7:14
    
Okay, right. When putting commands like that before \documentclass{...}, is that like in a sense making a global variable? –  night owl Aug 14 '11 at 7:35
    
no, as said it only prevents an option clash –  Herbert Aug 14 '11 at 8:08
1  
yes, they are global because it is the highest level –  Herbert Aug 14 '11 at 8:22

3 Answers 3

up vote 16 down vote accepted
\PassOptionsToPackage{dvipsnames}{xcolor}
\documentclass{...}
\usepackage[normalem]{ulem}
\usepackage[all]{xy}
\usepackage{xcolor}

However, it looks like that xcolor is already loaded by your documentclass or another package

share|improve this answer
    
@Herbet: Hmm, interesting if it could be the documentclass. The document looks like this: \documentclass[addpoints]{exam}. –  night owl Aug 14 '11 at 6:38
4  
@night owl: that class doesn't load a color package, so it is antother package which does it. However, you could use the above code to prevent option mismatch, it is always save. –  Herbert Aug 14 '11 at 6:42
    
@Herbet: Okay that is a good idea. You meant to say it is always "safe" right, besides using the word "save"? :) –  night owl Aug 14 '11 at 6:52
    
@night owl: uuh, always the same problem: my fingers and my brain are not synchronized ;-) –  Herbert Aug 14 '11 at 6:53
    
@Herbet: Hahahaha, no worries, I think 'almost' all of us computer gals/guys have this problem when we think on our toes but body mechanics is just too slow to tag along. –  night owl Aug 14 '11 at 6:57

Well, since Herbert provide a general solution for option clash, here is another solution:

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

Just put xcolor package before tikz package.

Explanation:

In LaTeX, you cannot load a package through \usepackage twice or more. If a package has been loaded, another \usepackage without any options will be safely ignored, but a \usepackage with some options will produce an option clash.

tikz package loads xcolor internally without any options. If you want to use xcolor with additional options, you can use it before tikz.


You can even use this way to prevent the option clash:

\documentclass[dvipsnames]{exam}
\usepackage{tikz}

Options for \documentclass are global. These options will be passed to any later packages if possible. It is especially useful if you want to pass an option to a package that loaded by the document class. However, it isn't as precise as \PassOptionsToPackage.

share|improve this answer
    
@ Leo: +1...Thanks alot. This was some very enlightening info to know and explanation was on point. Its good to learn something without any confusion. –  night owl Aug 14 '11 at 10:48
    
that makes sense if you are really sure, that all packages should get this option. This is not in all cases a good choice –  Herbert Aug 14 '11 at 13:35

Running

\documentclass[10pt]{article}
\usepackage[normalem]{ulem}
\usepackage[all]{xy}
\usepackage[dvipsnames]{xcolor}
\begin{document}
abcdefgh
\end{document}

does not produce any warnings or errors on a current TeXlive 2011 installation.

If you are using additional packages (hyperref is one that this problem is seen with, for example) here may well be ways round the problem: for example, try using the xcolor svgnames option if that color range is appropriate, use explicit \definecolor commands or try various diagnostic procedures.

Providing more information, including a complete but minimal size working example of the problem would help provide better responses.

share|improve this answer
    
@ mas: Hmm, wonder if that could be it. I currently am running of of MikTeX... –  night owl Aug 14 '11 at 6:38

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.