I was trying to draw multiple rectangular nodes side by side using
\begin{tikzpicture}[scale=0.675]
\def\size{0.625cm}
\node[rectangle,draw,line width=0.6pt,minimum size=\size,fill=cyan!50!black] (elem_0) at (0,0) {$x_0$};
\def\anchor{elem_0.east};
\foreach \txt in {x,y,z} {
\foreach \idx in {1,2,3} {
\node[rectangle,draw,anchor=west,line width=0.6pt,minimum size=\size,fill=cyan!50!black] (elem_\txt_\idx) at (\anchor) {$\txt_\idx$};
\def\anchor{elem_\txt_\idx.east};
}
\node[anchor=west] (separator_\txt) at (elem_\txt_3.east) {$...$};
\def\anchor{separator_\txt.east};
}
\end{tikzpicture}
but unfortunately it seems that the \def\anchor
is not updated inside the foreach-loop.
Is there any other way how to do this without unrolling the loops?
\xdef
instead of\def
to be global and to expand\txt
xdef
- it works perfectly