6

Ignasi's answer to Forest trees on the same line shows how to effectively draw two trees in the same forest environment using the phantom trick noted in the forest documentation.

Doing this, however, leads to extra vertical distance in the tree(s), which is quite noticeable when aligned with something else. For example, putting the trees inside of an \ex leads to the "top" of the trees starting below the example number.

enter image description here

Is there a way to eliminate this extra distance so that the "tops" of the two trees are aligned with the example number?

MWE

\documentclass{article}

\usepackage{forest}
\usepackage{gb4e}

\begin{document}

\begin{exe}
    \ex{
        \begin{forest} baseline
            [, phantom, s sep = 3em
                [asdf
                    [a]
                    [b]
                ]
                [asdf
                    [a]
                    [b]
                ]
            ]
        \end{forest}
    }
\end{exe}

\end{document}
  • Does it understand overlay option in the phantom node? (On the phone, no TeX sorry) – percusse Oct 6 '14 at 6:59
  • @percusse I'm not sure, to be honest. A quick search through the forest documentation returns nothing for the word "overlay". – Adam Liter Oct 6 '14 at 7:03
  • phantom means adding a phantom node with no visible connections to the roots of the two visible trees. This node is placed on the baseline as requested. Now you know why adjustbox can be useful, don't you? ;-) – egreg Oct 6 '14 at 7:38
  • @egreg True, though I was ultimately hoping things could be in the same forest environment to make it easier to draw arrows from one tree to the other. – Adam Liter Oct 6 '14 at 7:39
  • Just add next to the phantom option. If it goes up then good :) – percusse Oct 6 '14 at 11:11
3

Maybe I've misunderstood but could you not do something like this?

\documentclass{article}

\usepackage{forest}
\usepackage{gb4e}

\begin{document}

\begin{exe}
    \ex{
        \begin{forest}
          for tree={
            where level=0{
              for children={%
                l sep=0pt,
                baseline},
            }{},
          },
            [, phantom, s sep = 3em
                [asdf
                    [a]
                    [b]
                ]
                [asdf
                    [a]
                    [b]
                ]
            ]
        \end{forest}
    }
\end{exe}

\end{document}

children on baseline

  • Yes, this is perfect. Thanks cfr! For some reason, I could never get the l sep key to work, but now I can't remember what I tried. I deleted the files. Guess I should have read the manual more closely. – Adam Liter Oct 8 '14 at 2:44
  • 1
    @AdamLiter I always try to use it on the wrong level and can then never figure out why it seems to have no effect... In this case, though, if you left baseline applying to the phantom node, I couldn't get it to work. – cfr Oct 8 '14 at 2:46

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.