xcolor 包检测到未定义的颜色

xcolor 包检测到未定义的颜色

我正在写一本彩色书,需要定义 12 种颜色。但是,有时我会得到!package xcolor Error: Undefined color。但是,它没有指定任何颜色出错,但表明错误行包含\mainmatter。这是我的 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}

.log文件例如是 LaTeX 字体信息:T1/pmy/m/sl' in size <40> not available (Font) Font shape在输入行 243 上尝试使用字体形状 T1/pmy/m/it'。

<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>] 

通常我看到人们对包装有问题xcolor,他们确实有一个未定义的特定颜色。

笔记:

  • 我知道 MWE 是可编译的,但我的文档却不能,这让我感到压力很大。
  • 我检查了所有可能的线索,但......没有任何答案。

答案1

很难确定,因为没有提供适当的例子,但我猜你想要

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

因此第一章之前的颜色是“ black”而不是“

相关内容