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 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
4  
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
add comment

1 Answer

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:

\usetikzlibrary{fit}
\usetikzlibrary{calc}
% ...
\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
add comment

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.