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 have an existing graph with some nodes and edges, written with TikZ/pgf, and I need to add a couple of plates to them to make it a hierarchical model (similar to those in http://en.wikipedia.org/wiki/Hierarchical_Bayes_model).

I can hard-code the position and size of the rectangles, but I am wondering if there are ways to do this automatically? i.e. can I specify the nodes and circle-less text nodes that the rectangles need to bound to, and have the rectangles expand when they get bigger?

share|improve this question
Why don't you just present what you have done so far? Others a rarely motivated to reproduce that from scratch just for testing possible solutions. – Thorsten Donig Feb 22 '11 at 19:09
up vote 4 down vote accepted

You can draw such rectangles around nodes using the fit TikZ library. See the pgfmanual section 24 for a detailed description.

For a rectangle around a circle node which some space on the left side, like in your linked example, you can use the calc library:

% ...
\node [draw,circle] (A) {Text};
\node [draw,fit=(A) ($A.west - 3cm$)] {};
share|improve this answer
awesome, thanks! Just what I need. – ceiling cat Feb 22 '11 at 19:46

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.