I’m using TikZ to draw linguistic syntax trees where some nodes have textual labels and some nodes don’t. I’d like the branch from a labelless node to continue at the same angle into the right hand daughter (or alternatively into the left hand daughter) as the branch that went to the node, so that the two branches form a visually continuous line at the same angle. I worked out how to do so for one labelless node using a kluge of lots of anchor specifications for each child. This fails to work for more than one labelless node and it’s a really messy method anyway. There must be a better way to do this but I haven’t figured it out. Any suggestions? (I’m using XeTeX but this shouldn’t matter I think.)
\begin{tikzpicture}[level distance=2em,
sibling distance=4em,
parent anchor=south,
child anchor=north,
anchor=north,
align=center,
% every node/.style={draw}
]
\node{DP}
child {node {Qfr}}
child {node (dbar) {}
child[parent anchor=north, anchor=base] {node {D}}
child[parent anchor=north, anchor=base] {node {ΦP}
child[parent anchor=south, anchor=north] {node {CP}}
child[parent anchor=south, anchor=north] {node (phibar) {}
child[parent anchor=north, anchor=base] {node {Nml}}
child[parent anchor=north, anchor=south] {node (phibar2) {}
child[parent anchor=north, anchor=base] {node {Φ}}
child[parent anchor=north, anchor=base] {node {NP}}}}}};
\end{tikzpicture}
Best Answer
Instead of using empty nodes with
{}
, I would suggest you leave them out completely. To get the vertical spacing right, you can let all edges start at theparent anchor=center
, which will coincide with thenorth
anchor for the empty branches (so you get a continuous line) but be in the middle of the text nodes. To move the lines out of the text, you can specify atext depth
for all the nodes (which will not have an influence on the empty branches).