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'm trying to set some color on my caption like this

\usepackage[svgnames]{xcolor}
\usepackage[labelfont={color=red,bf}]{caption}

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

\documentclass[12pt]{report}
\usepackage[nottoc]{tocbibind}
\usepackage[lmargin=25mm,rmargin=20mm,tmargin=20mm,bmargin=20mm]{geometry}
\usepackage{array}
\usepackage{wrapfig}
\usepackage{hyperref}
\usepackage{natbib}
\usepackage{graphicx} % support the \includegraphics command and options
\usepackage{ucs}
\usepackage[utf8]{inputenc}
\usepackage[danish]{babel}
\usepackage[T1]{fontenc} 
\usepackage{listings}
\usepackage{lastpage} % for the number of the last page in the document
\usepackage{fancyhdr}
\usepackage{pdfpages}
\usepackage[document]{ragged2e}
\usepackage{setspace} 
\usepackage[svgnames]{xcolor}
\usepackage[labelfont={color=red,bf}]{caption}

\newcommand{\soa}{The Soma Project}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\newcommand\Signature[4]{\par\bigskip
\newcommand{\asp}{ASP.NET }
\newcommand{\aspm}{ASP.Net MVC 3}
\newcommand{\nh}{Nhibernate }

  \setlength\tabcolsep{0pt}
  \begin{tabular}{@{\hspace{.05\textwidth}}>{\centering\arraybackslash}p{.4\textwidth}
      @{\hspace*{.1\textwidth}}>{\centering\arraybackslash}p{.4\textwidth}@{\hspace{.05\textwidth}}}
  \multicolumn{2}{c}{#1, \today} \\[10ex]
  \rule{.4\textwidth}{0.4pt} & \rule{.4\textwidth}{0.4pt} \\
  #2 & #3 \\[10ex]
\end{tabular}
\par
}% for example, change the margins to 2 inches all roundhh

\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor =black,
    linkcolor=black,
    urlcolor  =black
}

\lstset{literate=%
{æ}{{\ae}}1
{å}{{\aa}}1
{ø}{{\o}}1
{Æ}{{\AE}}1
{Å}{{\AA}}1
{Ø}{{\O}}1
}


\pagestyle{fancy}

\lstset{extendedchars=\true}
\lstset{inputencoding=ansinew}

\fancyhf{}
\lhead{\leftmark}

%\lhead{Morten Starck \& Steffan Jensen}
\rhead{Section \thesection}
%\lfoot{\today}
\rfoot{Page \thepage\ af \pageref{LastPage}}
%\cfoot{\leftmark}
\usepackage{multirow}

\geometry{a4paper}

\usepackage{listings}
\usepackage{textcomp}
\definecolor{listinggray}{gray}{0.9}
\definecolor{lbcolor}{rgb}{0.9,0.9,0.9}
\lstset{
    backgroundcolor=\color{lbcolor},
    tabsize=4,
    rulecolor=,
    language=matlab,
        basicstyle=\scriptsize,
        upquote=true,
        aboveskip={1.5\baselineskip},
        columns=fixed,
        showstringspaces=false,
        extendedchars=true,
        breaklines=true,
        prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
        frame=single,
        showtabs=false,
        showspaces=false,
        showstringspaces=false,
        identifierstyle=\ttfamily,
        keywordstyle=\color[rgb]{0,0,1},
        commentstyle=\color[rgb]{0.133,0.545,0.133},
        stringstyle=\color[rgb]{0.627,0.126,0.941},
}

\lstdefinelanguage{CSharp}
{
 morecomment = [l]{//}, 
 morecomment = [l]{///},
 morecomment = [s]{/*}{*/},
 morestring=[b]", 
 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},
pdftitle={\soa},
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}}

\usepackage[section]{placeins}
share|improve this question
1  
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
add comment

1 Answer

up vote 10 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
add comment

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.