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 want to draw a big block with several small blocks, which is outside but adhere to the big one, as my picture showed below. I have no idea how to set "node distance" relatively based on big block's width and height. please help on that.

my output:

enter image description here

my expectation: I would like the two blocks in same horizon level, and the small one will adhere to big one.

enter image description here


\tikzstyle{big} = [rectangle,draw,fill=blue!20,text width = 5em,text centered,minimum width=6em,minimum height=8em]
\tikzstyle{small} = [rectangle,draw,fill=green!40,text width=0.8em, text centered,minimum height = 1em]

  \node [big] (in1) {1st instance};
  \node [small, above right of=in1] (port1) {1};

share|improve this question
You could use \node [small, anchor=north west, at=(in1.north east)] (port1) {1}; – Ulrike Fischer Dec 31 '13 at 16:21
It looks not what I want, I want the small box OUTSIDE of big box. but this anchor still keep the small boxes inside. – Coeus Wang Dec 31 '13 at 16:38
The box is outside for me. Are you sure you did use "west" in the anchor and "east" in the at? – Ulrike Fischer Dec 31 '13 at 16:57
What a amazing trick... I did use both as east. Now it works perfectly for me. – Coeus Wang Dec 31 '13 at 17:08
BTW - I also tried \matrix{} and it also works for me, and it can adjust column sep. :) – Coeus Wang Dec 31 '13 at 17:09
up vote 2 down vote accepted

You could use \node [small, anchor=north west, at=(in1.north east)] (port1) {1};

share|improve this answer

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.