I need the help of some smart people ;)
I want to draw a picture with TikZ, which is heavily based on randomization and I want to make it quite parametrized. It's actually a graph of n nodes where edges are incident to nodes based on previous node placement, so one can not do it all in only one for-loop, that's not possible (and i need x- and y-coordinates independently). In my plans i store x- and y-coordinates in an array and retrieve the data later for calculations. but I run into problems....
Array usage in TikZ is either limited or badly described (how to store/change data after initialization?)
So I use the package arrayjobx. below is a minimal non-working example (from my memory, unfortunately, my coding PC is currently not accessible; but I hope you see the problem without having a 100%-guaranteed compilable example):
\begin{tikzpicture}
\newarray\xcoord
\def \n {5}
\foreach \i in {1,...,\n}
{
% roll randomvalues and store them in arrays xcoord
\pgfmathsetmacro{\xe}{rnd*10}
\xcoord(\i)={\xe}
\foreach \j in {1,...,\i}
{
% access data in second nested loop; accessing is done with \checkArrayname and \cachedata to avoid parsing errors
\checkxcoord(\j)
\let\xf\cachedata
% next line is just for "debugging"
\node[draw,circle] at (\i,\j) {\xf};
}
}
\end{tikzpicture}
I can access the data without problems in the first loop. It's working fine. But in the second nested loop, no matter what value \j should have, \xf gets the value of \xcoord(\i), instead of \xcoord(\j). I tried it in different ways, using a counter for \j, using length-parameters instead of \let, etc. but the result is always the same.
What could cause this behaviour? Does anyone of you know a workaround?
