node names

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

node names

by Goebel, Juergen, OPES27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

node names

Hi,

Looking at the enclosed example my problem should be nearly
self-explanating.  I'd like to mulitply use a macro to define a node,
which I can refer to afterwards.  So, what do I have to change to
identify the nodes uniquely?

\documentclass{article}
\usepackage{TikZ}
\newcommand{\test}[1]{\node (a) at #1 {};}
\begin{document}
\begin{tikzpicture}
 \test{(0,0)} % test1
 \test{(0,1)} % test2
% \draw (test1.a) to (test2.a);
\end{tikzpicture}
\end{document}

Regards,

Juergen


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: node names

by Goebel, Juergen, OPES27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

RE: node names

I wrote:

    > Looking at the enclosed example my problem should be nearly
    > self-explanating.  I'd like to mulitply use a macro to define a node,
    > which I can refer to afterwards.  So, what do I have to change to
    > identify the nodes uniquely?


Let me try to answer my own question.  Maybe I found a solution:

\documentclass{article}
\usepackage{TikZ}
\newcommand{\test}[2]{\node (#2a) at #1 {};}
\begin{document}
\begin{tikzpicture}
 \test{(0,0)}{A} % test1
 \test{(0,1)}{B} % test2
 \draw (Aa) to (Ba);
\end{tikzpicture}
\end{document}

It seems(!) to work ...

Best,
Juergen



-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: node names

by Jens Fendler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Of course it works, but you don't even have to add the 'a' in your
'(#2a)'.

\newcommand{\test}[2]{\node (#2) at (#1) {};}
also works - and probably a little bit more intuitively.

Regards,
Jens

On Jul 08, 2008 11:42 AM, "Goebel, Juergen" <juergen.goebel@...>
wrote:

> I wrote:
>
> > Looking at the enclosed example my problem should be nearly
> > self-explanating.  I'd like to mulitply use a macro to define
> a node,
> > which I can refer to afterwards.  So, what do I have to change
> to
> > identify the nodes uniquely?
>
>
> Let me try to answer my own question.  Maybe I found a solution:
>
> \documentclass{article}
> \usepackage{TikZ}
> \newcommand{\test}[2]{\node (#2a) at #1 {};}
> \begin{document}
> \begin{tikzpicture}
>  \test{(0,0)}{A} % test1
>  \test{(0,1)}{B} % test2
>  \draw (Aa) to (Ba);
> \end{tikzpicture}
> \end{document}
>
> It seems(!) to work ...
>
> Best,
> Juergen
>
>




-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: node names

by Goebel, Juergen, OPES27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Jens Fendler wrote:

> Of course it works, but you don't even have to add the 'a' in your
> '(#2a)'.
>
> \newcommand{\test}[2]{\node (#2) at (#1) {};}
> also works - and probably a little bit more intuitively.

That's right, but ...

My example was quite shortened and in the original file
the macro looks more like this:

\newcommand{\test}[2]{%
   \node[shift={#1}] (#2a) at (0,0) {};  
   \node[shift={#1}] (#2b) at (0,1) {};  
   \node[shift={#1}] (#2c) at (1,1) {};  
   \node[shift={#1}] (#2d) at (1,0) {};
}

Therefore (I think) I need an identification of the various
nodes inside the macro.

Best,

Juergen

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users
LightInTheBox - Buy quality products at wholesale price