LaTeX 生成具有我想要的颜色的 Tikzpicture---但出现错误消息,表明颜色未定义

LaTeX 生成具有我想要的颜色的 Tikzpicture---但出现错误消息,表明颜色未定义

我编写了一些代码来生成tikzpicture淡紫色的颜色,稍后我想在其中添加一些文字。

\documentclass[12pt]{book}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{xcolor}

\begin{document}
\thispagestyle{empty}
 \begin{tikzpicture}[pencildraw/.style={ %
    decorate,
    decoration={random steps,segment length=2pt,amplitude=1pt}
    } %
]
\node[
preaction={fill=black,opacity=.5,transform canvas={xshift=1mm,yshift=-1mm}},
pencildraw,draw,fill=lavender!35,text width=0.89\textwidth,inner sep=5mm,align=justify] 
{\fontsize{14}{18}\selectfont {\bf ``.'' \vskip 1pt \hfill \emph{---}}};
\end{tikzpicture}
\end{document}

会产生错误消息:

在此处输入图片描述

但是,(惊喜!惊喜!),我试图制作的颜色的盒子:

在此处输入图片描述

问题:这怎么可能?错误消息表明 Latex 不知道我要求的颜色——但它却产生了我想要的颜色。有没有办法确定显示图片的 RGB 或 CYMK 数值是多少?这样的 tikizpictures 将成为更大文档的一部分,我不希望运行带有错误消息的代码,即使它产生了我想要的结果。

谢谢。

color顺便说一句,如果我使用包而不是包,也会发生同样的事情xcolor。并且,如果我要求填充颜色为薰衣草代替薰衣草!35---我得到了黑色。

答案1

  • 删除加载xcolor
  • 将选项svgnames(或)添加到文档类dvipsnmaes的选项中book
  • 而是lavender使用Lavender颜色名称:
\documentclass[12pt,svgnames]{book}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\thispagestyle{empty}
     \begin{tikzpicture}[pencildraw/.style={ %
 decorate,
 decoration={random steps,segment length=2pt,amplitude=1pt}
    } %
]
\node[
preaction={fill=black,opacity=.5,transform canvas={xshift=1mm,yshift=-1mm}},
pencildraw,draw,fill=Lavender!35,text width=0.89\textwidth,inner sep=5mm,align=justify]
{\fontsize{14}{18}\selectfont {\bf ``.'' \vskip 1pt \hfill \emph{---}}};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容