Sunday, 31 March 2013

LaTeX Error: Undefined color `ZedBoxColor'

The color package can be used to add colors to the text. A reference: http://en.wikibooks.org/wiki/LaTeX/Colors

However when circus package is used with color package together.
\documentclass[a4paper]{article}
\usepackage{xcolor}
\usepackage{circus}


An error occurs
LaTeX Error: Undefined color `ZedBoxColor'

Search ZedBoxColor and find it is defined in the zed.sty. Look like the @color@ is not defined or false.
\if@color@
  \@ifpackageloaded{color}{\relax}{%
    \RequirePackage[dvipsnames,usenames]{color}}
%  \definecolor{ZedBoxColor}{cmyk}{0.99,0,0.52,0}
  \definecolor{ZedBoxColor}{cmyk}{1,1,0,0}

  \definecolor{AnnotationColor}{cmyk}{0.98,0.13,0,0.43}
  \definecolor{ZedColor}{cmyk}{0.50,1,0,0}
\else
  \@ifpackageloaded{color}{\relax}{\def\color#1{\relax}}%
\fi


And check the @color@ definition in zed.sty. Its default is false
\newif\if@color@ \@color@false

But it can be set to true by the options.
\DeclareOption{color}{\@color@true}

DecalreOption is used to declare an option for the package.
\DeclareOption{<option>}{<code>}
The option is defined when loading the package
\usepackage[option1,option2]{package}
Thus one way to fix this error is to use the package of zed with option color
\documentclass[a4paper]{article}
\usepackage{xcolor}

\usepackage[color]{zed} 
\usepackage{circus}
 
But in circus.sty, it also provides several options similar to zed.sty
\DeclareOption{color}{\@color@true}
\DeclareOption{zed}{\@zed@true}
\DeclareOption{csp}{\@csp@true}


And zed and csp packages can be loaded by circus package indirectly.
\RequirePackageWithOptions{zed}
\@ifpackageloaded{csp}{\relax}{%
  \RequirePackageWithOptions{csp}}


\RequirePackage has the same syntax as the author command \usepackage
\RequirePackage[<options>]{<package>}[<date> ]
LoadClassWithOptions and RequirePackageWithOptions simply load a class or package file with exactly those options that are being used by the current class
\LoadClassWithOptions{<class-name>}[<date>]
\RequirePackageWithOptions{<package>}[<date>]

Finally, to eliminate the error, we can easily use the following options to load circus
\documentclass[a4paper]{article}
\usepackage{xcolor}

\usepackage[color,zed,csp]{circus}

No comments :

Post a Comment