TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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:

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

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
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. – Dmitry 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


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.