指定森林中級別之間的距離

指定森林中級別之間的距離

我希望在下面的樹中第一層和第二層之間有更多的空間。在 tikz-qtree 中我可以使用

\tikzset{level 1+/.style={level distance=3\baselineskip}} \tikzset{level 2+/.style={level distance=2\baselineskip}}

中是否有等效的東西forest

\documentclass{minimal}

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

答案1

你想要類似的東西嗎

l sep+=<some length>

這將減少層之間的距離<some length>

要將此增加限制為僅根節點和第一層之間的距離,您可以使用

for children={
  l sep-=<some length>,
}

來扭轉增加。 (可能有更直接的方法 - 這正是最容易得到的方法。)

以下分別比較預設值與1em和的增加2em

\documentclass{standalone}

\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
[S
  [NP [er\\he] ]
  [NP
    [Det [das\\the] ]
    [N [Buch\\book] ]
  ]
  [NP
    [Det [der\\the] ]
    [N [Frau\\woman] ]
  ]
  [V [gibt\\gives] ]
]
\end{forest}
\begin{forest}
sn edges,
l sep+=1em,
for children={
  l sep-=1em,
}
[S
  [NP [er\\he] ]
  [NP
    [Det [das\\the] ]
    [N [Buch\\book] ]
  ]
  [NP
    [Det [der\\the] ]
    [N [Frau\\woman] ]
  ]
  [V [gibt\\gives] ]
]
\end{forest}
\begin{forest}
sn edges,
l sep+=2em,
for children={
  l sep-=2em,
}
[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}

增加根節點<code>l sep</code>的效果

相關內容