naming nodes in foreach

View: New views
2 Messages — Rating Filter:   Alert me  

naming nodes in foreach

by Michael George :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd like to use foreach to set up a structure of nodes in a diagram, but
then refer back to individual nodes.  The nodes aren't in a grid, so I
can't use matrices.  However, tikz seems to forget all of the nodes I
define within a foreach.  I'd like to do something like the following:

\foreach \i in {0, 1, 2}
   \node (node-\i) at (...) {...);

\draw (node-0) -- (node-2);

is it possible?

Thanks!

--Mike



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: naming nodes in foreach

by GGBBRR :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The example you provide seems to work exactly as you want.
This works fine here:

\begin{tikzpicture}
\foreach \i in {0, 1, 2}
   \node (node-\i) at (\i,\i) {\i};

\draw (node-0) -- (node-2);
\end{tikzpicture}


Regards,
Gerben

Michael George wrote:
I'd like to use foreach to set up a structure of nodes in a diagram, but
then refer back to individual nodes.  The nodes aren't in a grid, so I
can't use matrices.  However, tikz seems to forget all of the nodes I
define within a foreach.  I'd like to do something like the following:

\foreach \i in {0, 1, 2}
   \node (node-\i) at (...) {...);

\draw (node-0) -- (node-2);

is it possible?

Thanks!

--Mike



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
pgf-users mailing list
pgf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users