I have a lot of nodes placed with tikz. Now I need to draw an rectangle around all these nodes.
I can draw the rectangle manually with
\draw [fill=gray!5] (2, -6) rectangle (18, 6.5)
(2, 6.5) node[below right,fill,draw] {Rectangle Title};
All my nodes are named and placed relatively:
...
\node [below=5cm of nodeA] (nodeB) {Node B text};
...
Best Answer
Let suppose, that your nodes have names. Among them are most outside
northernmost
,southernmost
,easternmost
andwesternmost
. In this case, as above comments say, the simple solution is:fit
\node[draw,inner sep=2mm,label=below:Rectangle Title,fit=(northernmost) (southernmost) (easternmost) (westernmost)] {};