2

Following the first example on page 33 of https://github.com/hackl/tikz-network/blob/master/manual.pdf I have been getting the following error below.

! Package pgf Error: No shape named C is known.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.6 ... layer={1,2},style=dashed]{data/ml_edges.csv}

?

Did I write something wrong in the code or omit something?

MWE

\documentclass{article}
\usepackage{tikz-network}
\thispagestyle{empty}
\begin{document}
\begin{tikzpicture}[multilayer=3d]
\Edges[vertices=data/ml_vertices.csv, layer={1,2},style=dashed]{data/ml_edges.csv}
\end{tikzpicture}
\end{document}

ml_vertices.csv

id, x, y ,size,color,opacity,label,layer
 A, 0,  0, .4 , green,  .9   ,  a  ,  1
 B, 1, .7, .6 ,      ,  .5   ,  b  ,  1
 C, 2,  1, .8 ,orange,  .3   ,  c  ,  1
 D, 2,  0, .5 ,   red,  .7   ,  d  ,  2
 E,.2,1.5, .5 ,  gray,       ,  e  ,  1
 F,.1, .5, .7 ,  blue,  .3   ,  f  ,  2
 G, 2,  1, .4 ,  cyan,  .7   ,  g  ,  2
 H, 1,  1, .4 ,yellow,  .7   ,  h  ,  2

ml_edges.csv

u,v,label,lw,color,opacity,bend,Direct
A,B, ab  ,.5,red   ,   1   ,  30,false
B,C, bc  ,.7,blue  ,   1   , -60,false
A,E, ae  , 1,green ,   1   ,  45,true
C,E, ce  , 2,orange,   1   ,   0,false
A,A, aa  ,.3,black ,  .5   ,  75,false
C,G, cg  , 1,blue  ,  .5   ,   0,false
E,H, eh  , 1,gray  ,  .5   ,   0,false
F,A, fa  ,.7,red   ,  .7   ,   0,true
D,F, df  ,.7,cyan  ,   1   ,   30,true
F,H, fh  ,.7,purple,   1   ,   60,false
D,G, dg  ,.7,blue  ,  .7   ,   60,false
2

IMHO the reason why it works in the manual but not in your case is that in TikZ coordinates are global. That is, when the manual compiles, first the examples on p. 32 are compiled, and they create the vertices. That is, the following works:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{data/ml_vertices.csv}
id,x,y,size,color,opacity,label,layer
A,0,0,.4,green,.9,a,1
B,1,.7,.6,purple,.5,b,1
C,2,1,.8,orange,.3,c,1
D,2,0,.5,red,.7,d,2
E,.2,1.5,.5,gray,,e,1
F,.1,.5,.7,blue,.3,f,2
G,2,1,.4,cyan,.7,g,2
H,1,1,.4,yellow,.7,h,2
\end{filecontents*} 
\begin{filecontents*}{data/ml_edges.csv}
u,v,label,lw,color,opacity,bend,Direct
A,B,ab,.5,red,1,30,false
B,C,bc,.7,blue,1,-60,false
A,E,ae,1,green,1,45,true
C,E,ce,2,orange,1,0,false
A,A,aa,.3,black,.5,75,false
C,G,cg,1,blue,.5,0,false
E,H,eh,1,gray,.5,0,false
F,A,fa,.7,red,.7,0,true
D,F,df,.7,cyan,1,30,true
F,H,fh,.7,purple,1,60,false
D,G,dg,.7,blue,.7,60,false
\end{filecontents*} 
\usepackage{tikz-network}
\thispagestyle{empty}
\begin{document}
\begin{tikzpicture}[multilayer=3d]
\Vertices[layer=1]{data/ml_vertices.csv}
\Vertices[layer=2]{data/ml_vertices.csv}
\Edges[style=dashed]{data/ml_edges.csv}
\end{tikzpicture}

\begin{tikzpicture}[multilayer=3d]
\Edges[vertices=data/ml_vertices.csv, layer={1,2},style=dashed]{data/ml_edges.csv}
\end{tikzpicture}
\end{document}

Why? Only because the coordinates are correctly generated in the first tikzpicture. If I comment it out, I reproduce the error you get because then the coordinates do not get defined. I guess you should inform the author of these issues, which some may want to call bugs.

  • 1
    thankfull again. I will open an issue github.com/hackl/tikz-network to advise the author and would agree to continue if I have further notes for further clarification. – Diego Bnei Noah Jul 31 at 0:42
  • 2
    @DiegoBneiNoah Yes, that's probably useful. Perhaps you can try to convince the author to test each example in a standalone document. – user121799 Jul 31 at 0:45
  • I will point out the suggestion of using standalone right now within this github issue in order to cover all the examples in the manual. Thank you for this specific advice and if you can explain why the use of standalone is so different and decisive. – Diego Bnei Noah Jul 31 at 0:48
  • 1
    @DiegoBneiNoah I tried to explain in my answer that coordinates are global. That is, when you define them in one tikzpicture they are are known in the subsequent ones. So the manual only works by accident. – user121799 Jul 31 at 0:51
  • Of course @marmot understood perfectly, just had no idea of the relationship of standalone format with the use of global settings of a package. I will be keeping an eye on updating this issue on github (github.com/hackl/tikz-network/issues/14) as I posted it and having modifications will add them here for everyone to know in the future :) – Diego Bnei Noah Jul 31 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.