4

The following is the MWE (Following code is taken from here, with slight modifications):

\documentclass[tikz]{standalone}
\tikzset{
    use bounding box relative coordinates/.style={
        shift={(current bounding box.south west)},
        x={(current bounding box.south east)},
        y={(current bounding box.north west)}
    },
    label/.style={draw=golden-rod},
}
\begin{tikzpicture}
\node[use as bounding box] {\includegraphics{example-image-a}};
\begin{scope}[use bounding box relative coordinates]
    \node[label][golden-rod] (Label) at (0.3,0.3) {GR};
    \draw[golden-rod] (Label.west) edge[-stealth] (0.1,0.35)
                      (Label.west) edge[-stealth] (0.1,0.25);
\end{scope}
\end{tikzpicture}
\end{document}

The problem I am facing is that I am not able to use the color Goldenrod available from the xcolor package. When I run the above code, I get the following errors:

  1. Package pgf Error: Unknown arrow tip kind 'golden'
  2. Package pgf Error: Unknown arrow tip kind 'rod'
  3. Package xcolor Error: Undefined color 'golden-rod'

When I change "golden-rod" to "Goldenrod" I get the following errors:

  1. Package pgf Error: I do not know the key '/tikz/Goldenrod' and I am going to ignore it. Perhaps you misspelled it.
  2. Package xcolor Error: Undefined color 'Goldenrod'.

In general, I am not able to use the colors whose name has two parts. Is there a way around this?

Aim
  • 633

1 Answers1

8

Apart from the typo (golden-rod instead of the correct Goldenrod), there are two more issues that must be addressed to make the code compilable.

First, it should be color=Goldenrod if you want the box border and the text in the color Goldenrod or draw=Goldenrow if you want black text inside of a Goldenrod-colored box.

(This solves Package pgf Error: I do not know the key '/tikz/Goldenrod' and I am going to ignore it. Perhaps you misspelled it.)

Second, the goldenrod color is only defined when loading xcolor with the svgnames option. Since you tikz internally also loads xcolor you can not use \documentclass[tikz]{standalone}\usepackage[svgnames]{xcolor}. Instead, I'd suggest using \PassOptionsToPackage{svgnames}{xcolor} \documentclass[tikz]{standalone}.

(This solves: Package xcolor Error: Undefined color 'Goldenrod'.)

A full, compilable MWE would look like the following:

\PassOptionsToPackage{svgnames}{xcolor}
\documentclass[tikz]{standalone}
\tikzset{
    use bounding box relative coordinates/.style={
        shift={(current bounding box.south west)},
        x={(current bounding box.south east)},
        y={(current bounding box.north west)}
    },
    label/.style={draw=Goldenrod},
}
\begin{document}
\begin{tikzpicture}
\node[use as bounding box] {\includegraphics{example-image-a}};
\begin{scope}[use bounding box relative coordinates]
    \node[label][color=Goldenrod] (Label) at (0.3,0.3) {GR};
    \draw[Goldenrod] (Label.west) edge[-stealth] (0.1,0.35)
                      (Label.west) edge[-stealth] (0.1,0.25);
\end{scope}
\end{tikzpicture}
\end{document}
leandriis
  • 62,593
  • I am required to use the above solution with the scrreprt – Koma-Script 'report' class. Can you please tell, how to load xcolor with the \documentclass{scrreprt} ? I used \PassOptionsToPackage{svgnames}{xcolor} in the preamble before \tikzset{.......}. I am getting the same error Package pgf Error: I do not know the key '/tikz/Goldenrod' and I am going to ignore it. Perhaps you misspelled it. – Aim May 02 '20 at 17:20
  • 2
    \documentclass{scrreprt} \usepackage[svgnames]{xcolor} \usepackage{tikz}. – leandriis May 02 '20 at 17:22