# Accolade to take objects together in TikZ

Is there a way to draw an accolade ({-symbol) that groups things together in TikZ? I want the accolade to group let's say three rectangles. That means the top of the upper reactangle must be the top of the accolade, and the bottom of the lower triangle the bottom of the accolade. Of course I can draw an accolade using a node, but I haven't found a way yet to make sure the size meets this constraint. Is there a solution or a workaround for it?

-

A solution more simple ( for me ) and with the possibility of scaling. I add the solution with Andrew's idea The code is very clear but we can not make a scale and perhaps there is a better solution to create more space vertically. The brace is more pretty with the matrix's delimiter.

\documentclass[]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{fit,calc,positioning,decorations.pathreplacing,matrix}
\begin{document}
\begin{tikzpicture}[decoration={brace}][scale=2]
\node [draw] (A) {A};
\node [draw,yshift=1cm] (B) at (A) {B};
\node [draw,yshift=1cm] (C) at (B) {C};
\node [fit=(A) (B) (C)] (fit) {};
\draw [decorate,line width=1pt] (fit.south west) -- (fit.north west);
\end{tikzpicture}
\hspace*{1cm}
\begin{tikzpicture}[scale=2]
\matrix [matrix of nodes,left delimiter=\{,nodes={draw}] {
A  \\[12pt] B \\[12pt] C \\
};
\end{tikzpicture}

\end{document}


-
An alternative is to use the matrix library and put left delimiter=\{ (I may be misremembering the syntax) on the "fitted" node. –  Andrew Stacey Apr 11 '11 at 20:21
I added your idea but you don't need to use the "fitted" node. The brace is more pretty but we can't scale the picture. It's not a big problem; this feature depends of the use of the picture –  Alain Matthes Apr 11 '11 at 20:46
The accolade needs to span a length of approx. 45 cm. This makes the accolade look like a normal line (only if you look very close you see it's an accolade), are there any parameters to the brace? (I mean the first option)? –  CommuSoft Apr 11 '11 at 20:56
I've found it myself: decoration={brace,amplitude=10} did the trick. Thanks. –  CommuSoft Apr 11 '11 at 21:04

You can use the fit TikZ library to create a rectangular node which encompasses the nodes, e.g. your three rectangles. Then you can use the node anchors to draw your { either using a scaled { character (\resizebox{!}{<height of fit>}{\{}) or using drawing commands. Two bezier curves should do it.

\documentclass[png]{standalone}

\usepackage{tikz}
\usetikzlibrary{fit,calc,positioning}

\begin{document}
\begin{tikzpicture}
\node [draw] (A) {A};
\node [draw,below of=A] (B) {B};
\node [draw,below of=B] (C) {C};
\node [fit=(A) (B) (C)] (fit) {};
\path let \p1=(fit.north west), \p2 = (fit.south east) in
node [left of=fit] {%
\pgfmathsetmacro\heightoffit{.8*(\y1-\y2)}%
\resizebox{!}{\heightoffit pt}{\{}%
};%
\end{tikzpicture}
\end{document}


### Result:

-
Alternatively, you could use the brace decoration. –  Caramdir Apr 11 '11 at 19:41
@Caramdir: Ah, I didn't know about that. Thanks. –  Martin Scharrer Apr 11 '11 at 19:59
I think the line width of the brace is ... very great ! :) –  Alain Matthes Apr 11 '11 at 20:01
@Altermundus: I noticed :-) Could be fixed by some horizontal-only down-scaling. But your solution seems to be preferable. –  Martin Scharrer Apr 11 '11 at 20:06
Andrew's idea is very fine too ! –  Alain Matthes Apr 11 '11 at 20:47