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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set some color on my caption like this


But it gives me this error "option clash for package xcolor". But then I look in the live preview it's does indeed to it. What am I doing wrong? This is the hole preample

\usepackage{graphicx} % support the \includegraphics command and options
\usepackage{lastpage} % for the number of the last page in the document

\newcommand{\soa}{The Soma Project}
\newcommand{\asp}{ASP.NET }
\newcommand{\aspm}{ASP.Net MVC 3}
\newcommand{\nh}{Nhibernate }

  \multicolumn{2}{c}{#1, \today} \\[10ex]
  \rule{.4\textwidth}{0.4pt} & \rule{.4\textwidth}{0.4pt} \\
  #2 & #3 \\[10ex]
}% for example, change the margins to 2 inches all roundhh

    filecolor =black,
    urlcolor  =black





%\lhead{Morten Starck \& Steffan Jensen}
\rhead{Section \thesection}
\rfoot{Page \thepage\ af \pageref{LastPage}}


        prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},

 morecomment = [l]{//}, 
 morecomment = [l]{///},
 morecomment = [s]{/*}{*/},
 sensitive = true,
 morekeywords = {abstract,  event,  new,  struct,
   as,  explicit,  null,  switch,
   base,  extern,  object,  this,
   bool,  false,  operator,  throw,
   break,  finally,  out,  true,
   byte,  fixed,  override,  try,
   case,  float,  params,  typeof,
   catch,  for,  private,  uint,
   char,  foreach,  protected,  ulong,
   checked,  goto,  public,  unchecked,
   class,  if,  readonly,  unsafe,
   const,  implicit,  ref,  ushort,
   continue,  in,  return,  using,
   decimal,  int,  sbyte,  virtual,
   default,  interface,  sealed,  volatile,
   delegate,  internal,  short,  void,
   do,  is,  sizeof,  while,
   double,  lock,  stackalloc,   
   else,  long,  static,   
   enum,  namespace,  string}

\hypersetup{pdfauthor={Morten T. Starck \& Steffan Jensen},
pdfsubject={Afsluttende Bachelor Projekt PBA2011},
pdfkeywords={Dette er under copy right 2012 fra Morten Starck \& Steffan Jensen. Samt Virtual Lab APs.},
pdfproducer={Morten Starck \& Steffan Jensen \today},
pdfcreator={pdflatex, \LaTeX}]{hyperref}}

share|improve this question
It's hard to tell without knowing more about your preamble. The error is caused by another package (or class) loading xcolor with different options. Are you using beamer? – egreg May 25 '12 at 22:42
I have just added the hole thing. For some reason i cant get it to display the hole thing as code block :( – mortenstarck May 25 '12 at 22:49
You should provide more information about what other packages you are including. BTW, adding \PassOptionsToPackage{svgnames}{xcolor} before \documentclass{...} may be helpful. You have to remove \usepackage[svgnames]{xcolor} from the preamble. – Harish Kumar May 25 '12 at 22:49
You might be interested in the matlab-prettifier package; see this answer. – Jubobs Apr 28 '14 at 15:37
up vote 22 down vote accepted

The xcolor package is loaded by listings. Put the line before \usepackage{listings}.

However your preamble is quite messy. It's most important that you call hyperref as the last package and put all options to geometry before fancyhdr.

The package ucs is useless with your settings.

share|improve this answer
I no that it's abit messy. But the problem is that i have added new things along the way and it has been put in radom :( . But it now works. Thanks – mortenstarck May 25 '12 at 22:59
Like Harish wrote \PassOptionsToPackage{svgnames}{xcolor} before the line \usepackage{listings} is fine and the problem is the same with TikZ. With \PassOptionsToPackage you can avoid conflicts between options. – Alain Matthes May 26 '12 at 5:02

Your Answer


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.