![减少森林中节点标签和连接线之间的距离](https://linux22.com/image/287121/%E5%87%8F%E5%B0%91%E6%A3%AE%E6%9E%97%E4%B8%AD%E8%8A%82%E7%82%B9%E6%A0%87%E7%AD%BE%E5%92%8C%E8%BF%9E%E6%8E%A5%E7%BA%BF%E4%B9%8B%E9%97%B4%E7%9A%84%E8%B7%9D%E7%A6%BB.png)
我使用以下代码来生成像图中左边两棵树。
\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}
我想减少这个距离,以便它看起来像右边的树(用 绘制tikz-qtree
)。有没有办法做到这一点(并将其设置为默认值)?
答案1
你想要类似的东西吗
l sep-=<some length>
这将减少层之间的距离<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}
for tree={
l sep-=1em,
},
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}
for tree={
l sep-=2em,
},
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}