木の葉を並べる

木の葉を並べる

次のようなツリーがありますが、一番左の葉は同期されていません。

\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}

ここに画像の説明を入力してください

私はついていきます 複数の木をベースラインに合わせる を追加しました\tikzset{every leaf node/.append style={text depth=0pt}}が、効果はありません。

答え1

強力なforestパッケージ (内部では 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}

ここに画像の説明を入力してください

すべてのノードの内容を中央揃えにするには、align=left を align=center に変更します (もちろん、これはリーフに対してのみ、または OER ケース ベースで実行できます)。

\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}

ここに画像の説明を入力してください

base=bottom実際のところ、すべてのリーフに 2 本の線があるため、このオプションはここでは必要ありません。

関連情報