3

I have the following tree in which the left-most leave is out of sync:

\documentclass{minimal}

\usepackage{tikz-qtree}

\begin{document}

\begin{tikzpicture}
\tikzset{level 1+/.style={level distance=3\baselineskip}}
\tikzset{level 2+/.style={level distance=2\baselineskip}}
\tikzset{frontier/.style={distance from root=8\baselineskip}}
\tikzset{every tree node/.style={align=left, anchor=north}}
\tikzset{every leaf node/.append style={text depth=0pt}}
\Tree[.S
       [.NP er\\he ]
       [.NP
         [.Det das\\the ]
         [.N Buch\\book ] ]
       [.NP
         [.Det der\\the ]
         [.N Frau\\woman ] ]
       [.V gibt\\gives ] ]
\end{tikzpicture}

\end{document}

enter image description here

I followed aligning several trees to the baseline and added \tikzset{every leaf node/.append style={text depth=0pt}}, but this does not have any effect.

3

If you are willing to use the powerful forest package (internally uses PGF/TikZ):

\documentclass{article}
\usepackage{forest}

\begin{document}

\begin{forest}
for tree={
  parent anchor=south, 
  child anchor=north,
  align=left,
  base=bottom
},
where n children=0{tier=word}{}
[S
  [NP [er\\he] ]
  [NP
    [Det [das\\the] ]
    [N [Buch\\book] ] 
  ]
  [NP
    [Det [der\\the] ]
    [N [Frau\\woman] ] 
  ]
  [V [gibt\\gives] ]
]
\end{forest}

\end{document}

enter image description here

To have all node contents centred, change align=left to align=center (of course, this can be done only for the leaves or on a oer case basis).

\documentclass{article}
\usepackage{forest}

\begin{document}

\begin{forest}
for tree={
  parent anchor=south, 
  child anchor=north,
  align=center,
  base=bottom
},
where n children=0{tier=word}{}
[S
  [NP [er\\he] ]
  [NP
    [Det [das\\the] ]
    [N [Buch\\book] ] 
  ]
  [NP
    [Det [der\\the] ]
    [N [Frau\\woman] ] 
  ]
  [V [gibt\\gives] ]
]
\end{forest}

\end{document}

enter image description here

The option base=bottom is, in fact, not required here since all your leaves have two lines.

  • This is the second answer that points me to forrest'. I guess I have to switch. The manual looks highly complex ... Do you have an easy way to center all leave items? "Frau" looks strange since "woman" is wider. tikz-qtree` does this in the same way. So this would have been my next question for tikz-qtree. – Stefan Müller Mar 26 '14 at 20:19
  • 1
    @StefanMüller change align=left to align=center. I'll edit the answer. – Gonzalo Medina Mar 26 '14 at 20:23
  • @StefanMüller Answer edited. And yes, I think you should consider changing to forest; it's really amazing. The documentation might seem complex, but it has numerous examples illustrating the commands. – Gonzalo Medina Mar 26 '14 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.