フォレスト内のノードラベルと接続線間の距離を短縮する

フォレスト内のノードラベルと接続線間の距離を短縮する

次のコードを使用して、図の左側の 2 つのようなツリーを生成します。

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

<code>l sep</code> の減少の影響

関連情報