排版具有不連續成分的依存語法樹

排版具有不連續成分的依存語法樹

我設法排版簡單的依存語法樹(排版依存語法樹),但現在想要有非投影圖。解決方案forest如下:

\documentclass{article}

\usepackage{forest}



\forestset{
dg edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=bottom,where n children=0{tier=word,edge=dotted,calign with current edge}{}}},
}


\begin{document}

\begin{forest}
dg edges
[V
  [N, phantom,no edge
    [L1, phantom,no edge 
      [L2, phantom,no edge 
        [L3, phantom,no edge   [ N,name=nacc [wen\\who] ] ] ] ] ]
  [glaubst\\believes] 
  [N [du\\you] ]
  [Subjunction
    [dass\\that]
    [V-fin
      [V-prt, name=vprt
        [N [ich\\I ] ]
        [gesehen\\seen] ]
      [habe\\have] ] ] ]
\draw (vprt.south)--(nacc.north);
\end{forest}


\end{document}

這會產生下圖:

在此輸入影像描述

我用虛擬節點填充了空樹位置並添加了這些虛擬no edge節點,以便這些虛擬節點沒有連接。另外,我用手從vprt到畫了一條線。nacc

差不多就這些了,但是我有兩個問題:

這樣可以做得更好(更簡單)嗎?

兩個N的對齊有問題。最左邊的 N 比右邊的 N 高。有沒有辦法讓它們在同一條線上?這種差異是由於幻影沒有高度造成的嗎?

答案1

您不需要no edge另外phantom。您可以使用另一個選項對齊兩個 N tier

\documentclass{article}

\usepackage{forest}

\forestset{
  dg edges/.style={%
    for tree={%
      parent anchor=south,
      child anchor=north,
      align=center,
      base=bottom,
      where n children=0{%
        tier=word,
        edge=dotted,
        calign with current edge}{}
    }
  },
}

\begin{document}

\begin{forest}
dg edges
[V
  [N, phantom
    [L1, phantom
      [L2, phantom
        [L3, phantom  [N, name=nacc, tier=mytier [wen\\who] ] ] ] ] ]
  [glaubst\\believes]
  [N [du\\you] ]
  [Subjunction
    [dass\\that]
    [V-fin
      [V-prt, name=vprt
        [N, tier=mytier [ich\\I ] ]
        [gesehen\\seen] ]
      [habe\\have] ] ] ]
\draw (vprt.south)--(nacc.north);
\end{forest}

\end{document}

調整樹

相關內容