Diagramming multiple inheritance with trees in LaTeX



Does anyone have experience making trees that show multiple inheritance in LaTeX? Something along these lines:


I’m not sure how they got the converging lines that lead to ‘Su-Wh-Rel’ and ‘That-Rel.’ Anyone done this before?



You can use the forest package for trees. Since it’s Tikz-based, you can just \draw the other lines later. Here’s what I do for the variable hierarchy:

% preamble:
% body
    \draw (p) -- (x) (i) -- (x);
  \caption{Variable hierarchy}

Resulting in the following:

The [,phantom] nodes are just empty nodes to help with spacing. If I remove them (and make the x node a child of the i node) it looks like this:


Thanks! Forest looks like a much better package to use than what I was doing.


Does anyone know how to connect the lines when using \draw, so that it looks like the first image?


If you use (nodename.north) and (nodename.south), that will draw lines from the very top and bottom, respectively. For example:

\draw (p.south) -- (x.north);

I’ve never used the forest package, so I don’t know how to make its lines behave similarly. When I’ve made this kind of hierarchy, I’ve done it directly in TikZ, using the [on grid] setting and placing nodes relative to each other.


Thanks, Guy! Here is a full working example for those using forest:
joinedges/.style={for tree={parent anchor=south, child anchor=north}},
agree/.style={tikz={\draw[-,dotted] () to[out=south,in=south] node[below]{} (#1);},}
[A [B [C] [D] [E, name=E]] [F, name=F [G] [H]]]
\draw (F.south) – (E.north);

This yields:

A phantom node like Mike suggests would probably help with the alignment, but in my case, this looked fine once I wrote out type names.