For drawing some extra edges in a grid I used the following code:
\begin{tikzpicture} \newcounter{xp} \newcounter{yp} \grGrid[prefix=a,RA=2,RB=2]{6}{6} \foreach \x in {0,2,4}{% \foreach \y in {1,3}{% \setcounter{xp}{\x} \setcounter{yp}{\y} \stepcounter{xp} \stepcounter{yp} \Edge(a\x;\y)(a\thexp;\theyp) } } \end{tikzpicture}
For some reason the following code does not work (producing the error ! Package pgf Error: No shape named a1 is known.
) Apparently, only counters are permitted as vertex indices.
\begin{tikzpicture} \grGrid[prefix=a,RA=2,RB=2]{6}{6} \foreach \x in {0,2,4}{% \foreach \y in {1,3}{% \pgfmathsetmacro{\xp}{\x+1} \pgfmathsetmacro{\yp}{\y+1} \Edge(a\x;\y)(a\xp;\yp) } } \end{tikzpicture}
See also: Original Source by Rafael
Note: The copyright belongs to the blog author and the blog. For the license, please see the linked original source blog.
Leave a Reply
You must be logged in to post a comment.