按照手册第 26 页的示例 https://github.com/hackl/tikz-network/当执行 latexmk -pdflua -pvc 或 latexmk -pdfxe -pvc 时,我收到以下错误。注意:已经尝试过https://github.com/hackl/tikz-network/issues/5:
! Package xkeyval Error: `R' undefined in families `vertex'.
See the xkeyval package documentation for explanation.
Type H <return> for immediate help.
...
l.6 \Vertices[RGB]{data/vertices_RGB.csv}
?
梅威瑟:
\documentclass{article}
\usepackage{tikz-network}
\thispagestyle{empty}
\begin{document}
\begin{tikzpicture}
\Vertices[RGB]{data/vertices_RGB.csv}
\end{tikzpicture}
\end{document}
编辑:正如@sebastiano 所要求的,这里是edges.csv的链接https://github.com/hackl/tikz-network/blob/master/doc/data/edges.csv用于我的 MWE。
答案1
问题在于标题中的空格。由于 etoolbox 的更改(它在命令内部使用 \ifstrempty 而不是 \ifblank),datatool 现在在这里更加挑剔。如果您将数据文件中的标题更改为
id,x,y,size,color,opacity,label,R,G,B
它再次编译。有问题的空间是后R,G,B。可以通过切换定义来测试问题:
\documentclass{article}
\usepackage{etoolbox}
\makeatletter
%old, ",R ," works
%\def\etb@ifdefempty #1{\expandafter \expandafter \expandafter \ifblank \expandafter \expandafter \expandafter {\expandafter \strip@prefix \meaning #1}}
%new, ",R ," fails
%\def\etb@ifdefempty #1{\expandafter \expandafter \expandafter \ifstrempty \expandafter \expandafter \expandafter {\expandafter \strip@prefix \meaning #1}}
\usepackage{tikz-network}
\thispagestyle{empty}
\begin{document}
\begin{tikzpicture}
\Vertices[RGB]{test-vertices.csv}
\end{tikzpicture}
\end{document}
数据文件中带有空格:
id,x,y,size,color,opacity,label,R ,G,B
A, 0, 0, .4 , green, .9 , a ,255, 0, 0
B, 1, .7, .6 , , .5 , b , 0,255, 0
C, 2, 1, .8 ,orange, .3 , c , 0, 0,255
D, 2, 0, .5 , red, .7 , d , 10,120,255
E,.2,1.5, .5 , gray, , e , 76, 55,255
编辑
您可以尝试以下补丁:(@@edges 可能也需要类似的补丁,也许还有更多的命令,因此最好由软件包作者来完成)。
\documentclass{article}
\usepackage{expl3}
\usepackage{tikz-network}
\makeatletter
\ExplSyntaxOn
\cs_set_eq:NN\vertex@trim@spacesN\tl_trim_spaces:N
\ExplSyntaxOff
\patchcmd\@@vertices{\DTLifeq}{\vertex@trim@spacesN\dtlkey\DTLifeq}{}{\fail}
\makeatother
\thispagestyle{empty}
\begin{document}
\begin{tikzpicture}
\Vertices[RGB]{test-vertices.csv}
\end{tikzpicture}
\end{document}