I'm trying to draw a specific tree, with two parents node linked to the same child. The problem is that one of the parent is outside the main tree.
Here's the code I have for the moment:
\documentclass{article}
\usepackage{tikz-qtree,tikz-qtree-compat}
%\usepackage{gb4e}
\usepackage{forest}
\begin{document}
%\begin{exe}
\begin{forest}
qtree edges/.style={for tree= parent anchor=north, child anchor=south}
[A, grow=north
[C, name=C, grow'=north
[D, grow=north ]
[E, name=t5, grow=north ]
]
[B, grow=north ]
]
\hspace{0.8cm}
[$F$, name=F, grow=north ]
%\draw (F.north) -- (C.south);
\end{forest}
%\end{exe}
\end{document}
I'd like the nodes F and C to be connected. I don't know why, but if I delete the dollar signs, node F doesn't even appear on my document.
Another thing is that I want the forest environment to be embedded in an example environment, but this doesn't work either.
Thanks in advance for your help!
Best Answer
There are various problems with your code. First, multirooted structures are not formally trees, so you can't expect tree drawing packages to handle them directly. See the following question for more discussion on techniques for this:
Furthermore, the syntax for a
gb4e
example requires that the example be introduced by the\ex
macro (within the{exe}
environment.)To handle the multidominance, I've used Ignasi's suggestion to create a node relative to the
-|
path between node A and E. You could also use the TikZpositioning
library, to manually place the node. I've also removed thetikz-qtree
package, since it's not needed if you're usingforest
. Since your 'tree' grows upwards, I've addedbaseline
to one of the terminal nodes so that it will align properly with the example number, and set the growth function globally for the tree. Also, you had a particular style for nodes in your example, but you never applied that style, and I've done that too.You should also load
gb4e
after most other packages, since it can cause problems otherwise.)