# Aligning forest trees and getting the bounding box right

I want to set the following figure:

I managed to recreate it using forest, but for reasons I do not understand, my command \menge, which I use for sets things that the forest trees are much larger than they are. I guess this has to do with the baseline of the trees. What I get is:

I was able to fix this using adjustbox but this is cumbersome. Here is what I have:

\documentclass{article}

\usepackage{forest}
\usetikzlibrary{tikzmark}

\newcommand{\menge}[1]{%
\mbox{%
$% \left\{% \ignorespaces#1% \right\}%$%
%\\[-1.5mm]
}%
}

\begin{document}
\begin{figure}
\menge{
\hspace{1em}
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp1}{VP}]]
\end{forest}}
\hspace{1em}
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp2}{VP}]]
\end{forest}
}
\hspace{1em}
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp3}{VP}]]
\end{forest}
}
\hspace{1em}
\begin{forest}
[VP
[geben]
[\subnode{vp4}{VP}]]
\end{forest}
}
\hspace{1em}
\begin{forest}
[\subnode{vp}{VP}
[$\epsilon$]]
\end{forest}
}
\hspace{1em}
}
\begin{tikzpicture}[overlay,remember picture,out=-90,in=90,dashed]
\draw (vp1) to (vp);
\draw (vp2) to (vp);
\draw (vp3) to (vp);
\draw (vp4) to (vp);
\end{tikzpicture}
\caption{Test caption}
\end{figure}

\end{document}


Apart from seeming redundant, my solution does not get the bounding box for the complete figure right. The dashed lines stick out and interfere with the caption.

• Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – cfr Jan 10 '15 at 2:48
• Hm. I would like to keep the normal braces, so since the tikz decoration looks different, this solution is not optimal. The other solution suggests drawing the braces by hand. This is not a general solution and similar to adding some \vspaceas in my original proposal. A reply to one of my other questions suggested a way to fix the baseline tex.stackexchange.com/questions/206728/… I included \forestset{begin draw/.code={\begin{tikzpicture}[baseline=(current bounding box.center)]}} after \menge{ and this gets the alignment right not bb. – Stefan Müller Jan 11 '15 at 14:18

Braces for mathematical expressions are always symmetrical to the math baseline. Draw independent braces:

\documentclass{article}
\usepackage{forest}
\usetikzlibrary{tikzmark}

\begin{document}
\begin{figure}
\raisebox{2em}{$\left\{\rule{0pt}{2.75em}\right.$}
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp1}{VP}]]
\end{forest}
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp2}{VP}]]
\end{forest}
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp3}{VP}]]
\end{forest}
\begin{forest}
[VP
[geben]
[\subnode{vp4}{VP}]]
\end{forest}
\begin{forest}
[\subnode{vp}{VP}
[$\epsilon$]]
\end{forest}
\begin{tikzpicture}[overlay,remember picture,out=-90,in=90,dashed]
\draw (vp1) to (vp);
\draw (vp2) to (vp);
\draw (vp3) to (vp);
\draw (vp4) to (vp);
\end{tikzpicture}
\raisebox{2em}{$\left.\rule{0pt}{2.75em}\right\}$}

\bigskip
\caption{Test caption}
\end{figure}

\end{document}


You can draw the braces with a TikZ decoration. Admitted, they're ugly, but there's no need for a box raised to some arbitrary height.

\usetikzlibrary{tikzmark,decorations,decorations.pathreplacing}

\newcommand{\menge}[1]{%
\begin{tikzpicture}
\draw node(tree){\ignorespaces#1};
\draw [decorate,decoration=brace]
(tree.south west) -- (tree.north west);
\draw [decorate,decoration=brace]
(tree.north east) -- (tree.south east);
\end{tikzpicture}%
}


• OK, thanks! Just for better understnading: Putting my trees into the node called tree causes tikzto determine the size of this object and this also solves the problem with the distance to the caption, right? – Stefan Müller Oct 17 '14 at 11:23
• I am not sure about the caption problem. You draw the dashed lines with an overlay/remember picture, so TikZ doesn't use them when it determines the size of the bounding box. I imagine that if the dashed lines become too deep, you'll end up with problems with the caption. If you draw the braces before drawing the dashed lines, you can draw the braces without overlay/remember picture. That should avoid problems with the caption. – user10274 Oct 17 '14 at 11:42