숲의 레벨 간 거리 지정

숲의 레벨 간 거리 지정

아래 트리에서 첫 번째 레벨과 두 번째 레벨 사이에 더 많은 공간을 두고 싶습니다. 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>,
}

증가를 되돌리려면. (더 직접적인 방법이 있을 수 있습니다. 이것은 가장 쉽게 구할 수 있는 방법입니다.)

다음은 기본값을 1em2em각각의 증가와 비교합니다.

\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> 증가 효과

관련 정보