0

The code below is an MWE illustrating a clash between the auto-pst-pdf and trimspaces packages. Code is a bit complicated because of the various things I want to do, but I've stripped all of those out. I'm running the code with pdflatex --shell-escape. The error that is thrown is:

! LaTeX Error: Option clash for package xcolor.

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

l.6 \usepackage
               {trimspaces

If I exclude the dvipsnames option to xcolor it runs without error.

Any advise as to how to fix the clash would be appreciated.

\documentclass{amsart}%
\usepackage{auto-pst-pdf}
%\usepackage{xcolor}
\usepackage[dvipsnames]{xcolor}
\usepackage{trimspaces}
\makeatletter
\newcommand*\DefineColorCommands[1]{\@define@color@commands{#1}}
\def\@define@color@commands#1{%
  \@define@color@commands@aux#1,\relax\q@stop
}
\def\@define@color@commands@aux#1,#2\q@stop{%
  \@ifundefined{#1}{%
    \expandafter\edef\csname\trim@spaces{#1}\endcsname##1{%
      \noexpand\textcolor{\trim@spaces{#1}}{##1}%
    }%
    \ifx\relax#2\else
      \@define@color@commands@aux#2\q@stop
    \fi
  }{}%
}
\makeatother
\DefineColorCommands{
    Apricot,
    Aquamarine,
    Bittersweet
}
\begin{document}
\end{document}
  • Load auto-pst-pdf after xcolor with option, or load[dvipsnames] as a document class option. – Bernard May 28 '18 at 23:56
  • Note that adding dvispsnames is exactly what LaTeX suggests if you do as it states in the error message you quoted and type h to get more help. – David Carlisle May 29 '18 at 7:09
  • Thanks Bernard and David. My actual application was much more complex than the MWE, but I managed to re-order things so that xcolor is now loaded before auto-pst-pdf, and all is well for now. It is, however, disturbing/frustrating that compilation success is so sensitive to package ordering – Leo Simon May 29 '18 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.