1

I was writing a coloured book that requires to define 12 colours. However, sometimes I get !package xcolor Error: Undefined color. However, it does not specifiy any colors went wrong but indicates the line of error contains \mainmatter. Here is my MWE.

\documentclass[12pt,a4paper,headinclude,openright]{scrbook}
\usepackage{etoolbox}
\usepackage[usenames,dvipsnames,svgnames,table,x11names]{xcolor}
\usepackage{microtype}
\definecolor{color01}{named}{Maroon}
\definecolor{color02}{named}{Firebrick3}
\renewcommand\chapterbackcolor{%
\ifcase\value{chapter} \or color01\or color02\fi}
\usepackage[listings,theorems,skins,breakable]{tcolorbox}
%======================== Ch.1 boxes ===========================
\tcbset{exercisestyle01/.style={arc=0.5mm, fonttitle=\sffamily\bfseries,colback=LightPink1,colframe=color01}}

\newtcolorbox[auto counter,number within=chapter,list inside=eg]%
{examples01}[2][]{exercisestyle01,
title={Example ~\thetcbcounter: #2}}
%===============================================================
\begin{document}
\begin{examples01}{Equation of position of double pendulum}
With two masses $m_1$ and $m_2$ are suspended on rigid string has length $r_1$ and $r_2$. Find the possible co-ordinates with respect to the origin point.
\tcblower
First of all, it is a rotational motion, hence it requires co-ordinate systems to consist of angle co-ordinates. Since the $y$-axis is constant during motion, we imagine a cylindrical plane pass through the $y$-$z$ plane. There should be angles denoted as $\theta_1$ for $m_1$, and $\theta_2$ for $m_2$. (Note that the angles are not shown in here)

However, the double pendulum is hung not from the origin \footnote{It can be due to our choice of reference frame.}. It can be said it is translated to a point where the pivot is. Such that the position, although not given in the diagram, is $A(x_0,y_0,z_0)$.
\end{examples01}
\backmatter
\end{document}

The .log file is such as LaTeX Font Info: Font shape T1/pmy/m/sl' in size <40> not available (Font) Font shapeT1/pmy/m/it' tried instead on input line 243.

<example-image-a.png, id=188, 401.5pt x 301.125pt>
File: example-image-a.png Graphic file (type png) <use example-image-a.png>
Package pdftex.def Info: example-image-a.png used on input line 243.
(pdftex.def)             Requested size: 85.35896pt x 42.67642pt.


! Package xcolor Error: Undefined color ` '.

See the xcolor package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.243 \mainmatter

Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

LaTeX Font Info:    Font shape `T1/pmy/m/sl' in size <12> not available 
(Font)              Font shape `T1/pmy/m/it' tried instead on input line 243.

! Package pgfkeys Error: I do not know the key '/tikz/ ' and I am going to ignore it. Perhaps you misspelled it.

See the pgfkeys package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.243 \mainmatter

This error message was generated by an \errmessage
command, so I can't give any explicit help.
Pretend that you're Hercule Poirot: Examine all clues,
and deduce the truth by order and method.

LaTeX Font Info:    Font shape `T1/pmy/m/sl' in size <17.28> not available
(Font)              Font shape `T1/pmy/m/it' tried instead on input line 243.

! Package xcolor Error: Undefined color `'.

See the xcolor package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.243 \mainmatter

Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

[5 <c:/texlive/2013/texmf-dist/tex/latex/mwe/example-image-a.png>] 

Normally I saw people have problems with xcolor package, they do have a specific colour undefined.

Note:

  • I understand that the MWE is compilable, but my document is not, which stresses me.
  • I examined all possible clues, and... nothing solved.
  • Your MWE generates the error ! LaTeX Error: \chapterbackcolor undefined. and no error about colours – David Carlisle May 28 '14 at 13:30
4

Hard to be sure as no proper example is provided but I would guess that you want

\renewcommand\chapterbackcolor{%
\ifcase\value{chapter}black\or color01\or color02\fi}

so that the colour before the first chapter is "black" rather than ""

  • Yes, I found that this was my mistake of defining a (space) as a colour instead of color01. – SHY.John May 28 '14 at 13:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.