1

I have written some code to produce a tikzpicture with a lavender color that I later want to add some text to.

\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}

which produces the error messages:

enter image description here

But, (surprise! surprise!), the box with the color I am trying to produce:

enter image description here

QUESTION: How can this be? The error messages indicate that Latex does not know the color I am asking for---yet it produces the color I want. Is there a way I can determine what the RGB or CYMK numbers are for the displayed picture? Such tikizpictures will be part of a larger document and I prefer not to run the code with error messages even though it is producing what I want.

THANK YOU.

Incidentally, the same thing happens if I use the color package instead of the xcolor package. And, if I ask the fill color to be lavender instead of lavender!35---I get a black for a color.

DDS
  • 8,816
  • 4
  • 9
  • 36
  • 1
    Hmmm... That patch seems quite gray (black!35). Btw, off topic, but \bf is deprecated since more than 20 years... – Rmano Feb 23 '21 at 21:10
  • 1
    You can see the list of predefined colors at page 38 here: http://mirrors.ctan.org/macros/latex/contrib/xcolor/xcolor.pdf, I can't see lavender there – Rmano Feb 23 '21 at 21:15
  • 1
    As @Rmano says, the fill color of that node is gray. I'm guessing it just reverts to the default black somehow. (TikZ already loads xcolor by the way, so the \usepackage{xcolor} is actually redundant.) – Torbjørn T. Feb 23 '21 at 21:17
  • 1
    There is a Lavender color if you pass the option svgnames to xcolor (notice the uppercase L). I do not know how tikz calls it, so maybe you need a \PassOptionToPackage{svgnames}{xcolor} before loading tikz (can't check now), see https://tex.stackexchange.com/questions/51488/option-clash-with-xcolor-and-tikz. https://tex.stackexchange.com/questions/296500/undefined-color-under-tikz-code – Rmano Feb 23 '21 at 21:23
  • @Rmano Would you know, offhand, if there is a way in LaTeX (or perhaps some other means) to determine the RGB numbers given a colored box of unknown color such as the one I posted? I suspect not, but perhaps there is some other available means to do that---If you know of any way that could be done, I think that would be very useful. – DDS Feb 23 '21 at 21:54
  • @mchristian you can use a color picker (plenty of them for every OS, I think), but this is not so easy. Conversion from a theoretical color in a document to rgb can be quite complex depending on the output device. Look for color managed devices... – Rmano Feb 23 '21 at 22:07
  • @Rmano Thank you. – DDS Feb 23 '21 at 22:54

1 Answers1

2
  • remove loading xcolor package
  • add option svgnames (or dvipsnmaes) to options of book document class
  • instead lavender use Lavender for color name:
\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}

enter image description here

Zarko
  • 296,517