Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to place variable number of additional nodes on the border of the rectangle. I suggest it to look in a somewhat following way:

\node[name=R, my rectangle=top:3 bottom:1 left:2 right:1] {Node R};

or even better:

\node[my rectangle=top:3 bottom:1 left:2 right:1] (R) {Node R};

As nodes are not parts of the path and are stored for execution at the end of path construction, both cases should be equivalent. Anyway, this node definition should result in implicit defining of nodes/coordinates named, respectively: R top 1, ..., R top 3, R bottom 1, R left 1, R left 2, R right 1.

Having looked into pgfmanual I found there a key /tikz/name, but failed in accessing it's value from my rectangle/.code.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

As far as I can tell, the node name is only available after the node has been constructed. Then it is stored in \tikzlastnode. You need to construct your additional nodes after the main node. This is done with the append after command key:

\begin{tikzpicture}
    \node[append after command={node[below] {\tikzlastnode}}] (node name) {X};
\end{tikzpicture}

Your code will probably be quite similar to the code for creating labels. So you should have a look at the code below % Label and pin options in tikz.code.tex (in texmf/tex/generic/pgf/frontendlayer/tikz/).

share|improve this answer
1  
after node path seems to be deprecated nowadays (I use PGF v2.10). Anyway, you've pointed me to the right direction. For those, who are interested, there is an option append after command. –  Dmitrii F. Volosnykh Apr 9 '11 at 17:35
    
@Dmitry: Thanks, I changed the answer accordingly. I was reading the code from the wrong version (in addition to TL 2010, I also have the Ubuntu packages installed for testing). –  Caramdir Apr 9 '11 at 20:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.