14

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?

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

3 Answers 3

21
\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

5
  • @Herbet: Hmm, interesting if it could be the documentclass. The document looks like this: \documentclass[addpoints]{exam}.
    – night owl
    Commented Aug 14, 2011 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.
    – user2478
    Commented Aug 14, 2011 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
    Commented Aug 14, 2011 at 6:52
  • @night owl: uuh, always the same problem: my fingers and my brain are not synchronized ;-)
    – user2478
    Commented Aug 14, 2011 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
    Commented Aug 14, 2011 at 6:57
11

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.

2
  • @ 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
    Commented Aug 14, 2011 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
    – user2478
    Commented Aug 14, 2011 at 13:35
1

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.

1
  • @ mas: Hmm, wonder if that could be it. I currently am running of of MikTeX...
    – night owl
    Commented Aug 14, 2011 at 6:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .