tikzset+code 错误消息

tikzset+code 错误消息

我正在编译以下代码

\documentclass[tikz]{standalone}

\usepackage[rgb]{xcolor}
\usepgflibrary {shadings}

\begin{document}
    \begin{tikzpicture}

        \tikzset{%
            vertex/.pic={%
                code={%
                    \shade[shading=radial, outer color=cyan!80!black, inner color = white] (0, 0) circle (0.1cm);
                }}}
        \path (0, 0) pic[color=red] {vertex};
    \end{tikzpicture}
\end{document}
  1. 生成的图像是青色而不是红色[这不太重要]
  2. 日志包含
Missing character: There is no c in font nullfont!
Missing character: There is no o in font nullfont!
Missing character: There is no d in font nullfont!
Missing character: There is no e in font nullfont!
Missing character: There is no = in font nullfont!

我的问题:为什么会发生第二种情况?

答案1

应该没有code=。直接添加代码(但 0.1cm 半径相当小,你看不到太多):

\PassOptionsToClass{rgb}{xcolor}
\documentclass[tikz]{standalone}

\usepgflibrary {shadings}

\begin{document}
    \begin{tikzpicture}
        \tikzset{%
            vertex/.pic={%
                    \shade[shading=radial, outer color=cyan!80!black, inner color = white] (0, 0) circle (0.1cm);
                }}
        \path (0, 0) pic[color=red] {vertex};
    \end{tikzpicture}
\end{document}

相关内容