# Dependency trees with crossings and dotted lines

For a presentation I need to refer to a paper which uses a certain kind of dependency tree:

Since I wanted to build some examples on my own, I'd be glad to rebuild this. I've tried several linguistic tree packages (qtree, xytree, tkiz, parsetree, etc.) but I haven't figured out how to rebuild this. It would be nice if someone could rebuild this (or a simpler example).

Note: Important for later interpretation are the dotted lines, the baseline and the ability to "cross" the structure (like $X_{2}^{2}$ does).

I don't know much about these kinds of trees, but it appears that the nodes are organized in rows and columns, which you are not likely to get with any of the regular tree drawing packages. So if that's important, it would make sense to use a matrix to do this. Here's an example using TikZ.

Some notes about the syntax used here. When specifying a matrix of nodes, you can add names to any node by using the |(<node-name>)| notation before the node text. Alternatively, you can use the (<matrix-row-column>) notation. Which notation you use is mainly a matter of preference: naming individual nodes makes your code a bit more readable, but requires more typing. In this example, I've used a mixture of both methods, since the last row really doesn't require named nodes for readability.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}

\begin{tikzpicture}
\matrix [matrix of math nodes,row sep=1cm,column sep=.5cm,nodes={outer sep=0pt}] (M) {
& & & & & |(1-0)| X^{1}_{0} &\\
& & |(2-1)| X^{2}_{1} & |(2-2)| X^{2}_{2} & & & |(2-3)| X^{2}_{3}\\
|(3-1)| X^{3}_{1} & |(3-2)| X^{3}_{2} &  & & |(3-3)| X^{3}_{3}  &\\
'X^{3}_{1} & 'X^{3}_{2} & 'X^{2}_{1} & 'X^{2}_{2} & 'X^{3}_{3} & 'X^{1}_{0} & 'X^{2}_{3}\\
};
\draw (1-0) -- (2-1);
\draw (1-0) -- (2-2);
\draw[dotted] (1-0) -- (M-4-6);
\draw (1-0) -- (2-3);
\draw (2-1) -- (3-1);
\draw (2-1) -- (3-2);
\draw[dotted] (2-1) -- (M-4-3);
\draw (2-2) -- (3-3);
\draw[dotted] (2-2) -- (M-4-4);
\draw[dotted] (2-3) -- (M-4-7);
\draw[dotted] (3-3) -- (M-4-5);
\draw[dotted] (3-1) -- (M-4-1);
\draw[dotted] (3-2) -- (M-4-2);
\path[draw] (M-4-1.north west) to (M-4-7.north east) node[right=2pt] {P};
\end{tikzpicture}
\end{document}