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};

  • 1
    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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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