向森林中的树添加没有内容的节点

向森林中的树添加没有内容的节点

我切换到forest现在我想知道如何绘制下面的图片: 在此处输入图片描述

我有下面的代码,但我找不到如何正确连接dass。我尝试了幻影节点,但线条没有画出来。

\documentclass{article}

\usepackage{forest}
\forestset{
sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=bottom,where n children=0{tier=word}{}}}, 
background tree/.style={for tree={text opacity=0.2,draw opacity=0.2,edge={draw opacity=0.2}}}
}

\begin{document}

\begin{forest}
sn edges
[{V3[+{\sc fin},+{\sc mc}]}
  [{N2[acc,+{\sc top}]} [wen\\who] ]
  [{V3[+{\sc mc}]/N2[acc]}
    [{V[9,+{\sc mc}]} [glaubt\\believes] ]
    [{N2[nom]} [du\\you] ] 
    [{V3[+dass,$-${\sc mc}]/N2[acc]} 
      [dass\\that]
      [{V3[$-$dass,$-${\sc mc}]/N2[acc]} 
         [{N2[nom]} [ich\\I] ]
         [{V[6,$-${\sc mc}]} [gesehen habe\\seen have,triangle] ] ] ] ] ]
\end{forest}

\end{document}

答案1

添加一个空节点,并将空节点的形状更改为coordinate使用

empty nodes/.style={
  delay={where content={}{shape=coordinate,for parent={for children={anchor=north}}}{}}}
}

在此处输入图片描述

代码:

\documentclass{article}

\usepackage{forest}
\forestset{
sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=bottom,where n children=0{tier=word}{}}}, 
background tree/.style={for tree={text opacity=0.2,draw opacity=0.2,edge={draw opacity=0.2}}},
empty nodes/.style={
  delay={where content={}{shape=coordinate,for parent={for children={anchor=north}}}{}}}
}

\begin{document}

\begin{forest}
sn edges,empty nodes
[{V3[+{\sc fin},+{\sc mc}]}
  [{N2[acc,+{\sc top}]} [wen\\who] ]
  [{V3[+{\sc mc}]/N2[acc]}
    [{V[9,+{\sc mc}]} [glaubt\\believes] ]
    [{N2[nom]} [du\\you] ] 
    [{V3[+dass,$-${\sc mc}]/N2[acc]} 
      [{}[dass\\that] ]
      [{V3[$-$dass,$-${\sc mc}]/N2[acc]} 
         [{N2[nom]} [ich\\I] ]
         [{V[6,$-${\sc mc}]} [gesehen habe\\seen have,triangle] ] ] ] ] ]
\end{forest}

\end{document}

答案2

它使用你的想法和幻影节点以及以下name论点:

\documentclass{article}

\usepackage{forest}
\forestset{
sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=bottom,where n children=0{tier=word}{}}}, 
background tree/.style={for tree={text opacity=0.2,draw opacity=0.2,edge={draw opacity=0.2}}}
}

\begin{document}

\begin{forest}
sn edges
[{V3[+{\sc fin},+{\sc mc}]}
  [{N2[acc,+{\sc top}]} [wen\\who] ]
  [{V3[+{\sc mc}]/N2[acc]}
    [{V[9,+{\sc mc}]} [glaubt\\believes] ]
    [{N2[nom]} [du\\you] ] 
    [{V3[+dass,$-${\sc mc}]/N2[acc]},name=A 
      [,phantom [ dass\\that,name=B,edge={}]]
      [{V3[$-$dass,$-${\sc mc}]/N2[acc]}
         [{N2[nom]} [ich\\I] ]
         [{V[6,$-${\sc mc}]} [gesehen habe\\seen have,triangle] ] ] ] ] ]
\draw  (B) --+(0,2.5)--(A);
\end{forest}

\end{document}

在此处输入图片描述

相关内容