3

I want to set the following figure: enter image description here

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:

enter image description here

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

\documentclass{article}                         


\usepackage{forest}
\usetikzlibrary{tikzmark}

\usepackage{adjustbox}

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



\begin{document}
\begin{figure}
\menge{ 
\hspace{1em}
\adjustbox{valign=c}{%
\begin{forest}
[VP
        [NP$\downarrow$]
        [\subnode{vp1}{VP}]]
\end{forest}}
\hspace{1em}
\adjustbox{valign=c}{%
\begin{forest}
[VP
        [NP$\downarrow$]
        [\subnode{vp2}{VP}]]
\end{forest}
}
\hspace{1em}
\adjustbox{valign=c}{%
\begin{forest}
[VP
        [NP$\downarrow$]
        [\subnode{vp3}{VP}]]
\end{forest}
}
\hspace{1em}
\adjustbox{valign=c}{%
\begin{forest}
[VP
        [geben]
        [\subnode{vp4}{VP}]]
\end{forest}
}
\hspace{1em}
\adjustbox{valign=c}{%
\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
  • Then please consider posting your solution as an answer and marking that one as accepted. There is no problem answering your own questions and you can link to the other answer to give its author credit, and explain why you preferred that solution to the others posted here. (That will help other people, who might have different requirements, select the solution which will best fit their needs.) Remember that questions are supposed to help many users - not just the person who posts the question - so posting your own answer, when appropriate, is a way of adding value to your questions. – cfr Jan 11 '15 at 16:38
3

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}
\quad
\begin{forest}
[VP
        [NP$\downarrow$]
        [\subnode{vp2}{VP}]]
\end{forest}
\quad
\begin{forest}
[VP
        [NP$\downarrow$]
        [\subnode{vp3}{VP}]]
\end{forest}
\quad
\begin{forest}
[VP
        [geben]
        [\subnode{vp4}{VP}]]
\end{forest}
\quad
\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}

enter image description here

3

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}%
}

tree in braces

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.