Diagramming multiple inheritance with trees in LaTeX


#1

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

image

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

Thanks!


#2

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:
\usepackage{forest}
\newcommand\nd[1]{\texttt{#1}}
% body
\begin{figure}[htb]
  \centering\small
  \begin{forest}
    [\nd{u}
      [\nd{i},name=i,calign=last
        [\nd{e}]
        [,phantom]
      ]
      [,phantom
        [\nd{x},name=x]
      ]
      [\nd{p},name=p,calign=first
        [,phantom]
        [\nd{h}]
      ]
    ]
    \draw (p) -- (x) (i) -- (x);
  \end{forest}
  \caption{Variable hierarchy}
  \label{fig:var-hier}
\end{figure}

Resulting in the following:
vh

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:
vh2


#3

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