[Tex/LaTex] Making mixed trees with and without text-containing nodes

linguisticstikz-pgftikz-treestrees

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}

Output of code above.

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 the parent anchor=center, which will coincide with the north 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 a text depth for all the nodes (which will not have an influence on the empty branches).

\begin{document}
\begin{tikzpicture}[
    level distance=2em,
    sibling distance=4em,
    anchor=north,
    parent anchor=center,
    child anchor=north,
    text depth=2.5ex % Use this to define the vertical space between the entering and exiting edge of a text node
]
\node{DP}
    child {node {Qfr}}
    child {
        child {node {D}}
        child {node {$\Phi$P}
            child {node {CP}}
            child {
                child {node {Nml}}
                child {
                    child {node {$\Phi$}}
                    child {node {NP}}}}}};
\end{tikzpicture}

\end{document}