![树层之间的距离](https://linux22.com/image/407635/%E6%A0%91%E5%B1%82%E4%B9%8B%E9%97%B4%E7%9A%84%E8%B7%9D%E7%A6%BB.png)
请问,我想调整树层之间的距离,如图所示。有没有办法改变间隔?谢谢。此致。
我想要编辑的实际代码如下:
\documentclass[a4paper,10pt]{article}
\usepackage{geometry}
\usepackage{forest}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{shadows}
\begin{document}
\tikzset{
my node style/.style={
font=\small,
top color=white,
bottom color=blue!25,
rectangle,
rounded corners,
minimum size=6mm,
draw=blue!75,
very thick,
drop shadow,
align=center,
}
}
\forestset{
my tree style/.style={
for tree={
parent anchor=south,
child anchor=north,
l sep+=5pt,
my node style,
edge={draw=blue!50, thick},
edge path={
\noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(0,-7.5pt) -| (.child anchor)\forestoption{edge label};
},
if n children=3{
for children={
if n=2{calign with current}{}
}
}{},
delay={if content={}{shape=coordinate}{}}
}
}
}
\centering
\begin{forest}
my tree style
[Paletizador
[Inicialização\\de sistema
[Sensor X]
[Acção Y]
]
[Sacos
[
[
[Linha/Coluna
[Garra]
[Rodar Garra]
[Acção Y2]
]
[Euro Pallet]
[{Disposição $xyz$}
[{$x=?$}]
[{$y=?$}]
[{$z=?$}]
]
]
]
]
[Sistema de despacho
[Sensor de peso\\/contador]
[Tapete rolante\\de saída]
]
]
\end{forest}
\end{document}
答案1
调整l sep
垂直间隙 -s sep
调整水平间隙 - 间隙可以按照您在开始时设置的样式进行全局调整,也可以针对各个级别进行设置
我已经在一个单独的层面上完成了它l sep= 10mm, s sep=20mm
——我相信你会进一步尝试
简短而简洁的 pdf 位于这里。
您可以为这些参数指定绝对值,或者增加或减少森林计算出的默认值。这可以通过乘法(例如 l*=3 将默认值乘以 3)或加法或减法(例如 l+=3mm 将默认值增加 3mm,l-=3mm 将默认值减去 3mm)来实现。
这些参数可以全局应用于整个树,如下所示:
例子
\begin{forest}
for tree={s sep=10mm, inner sep=0, l=0}
[CP
[C]
[IP
[I]
[VP [V] [NP]]
]
]
\end{forest}
数学家协会
\documentclass[a4paper,10pt]{article}
\usepackage{geometry}
\usepackage{forest}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{shadows}
\begin{document}
\tikzset{
my node style/.style={
font=\small,
top color=white,
bottom color=blue!25,
rectangle,
rounded corners,
minimum size=6mm,
draw=blue!75,
very thick,
drop shadow,
align=center,
}
}
\forestset{
my tree style/.style={
for tree={
parent anchor=south,
child anchor=north,
l sep+=5pt,
my node style,
edge={draw=blue!50, thick},
edge path={
\noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(0,-7.5pt) -| (.child anchor)\forestoption{edge label};
},
if n children=3{
for children={
if n=2{calign with current}{}
}
}{},
delay={if content={}{shape=coordinate}{}}
}
}
}
\centering
\begin{forest}
my tree style
[Paletizador,s sep=20mm, l sep =10mm %<--------change made here
[Inicialização\\de sistema
[Sensor X]
[Acção Y]
]
[Sacos
[
[
[Linha/Coluna
[Garra]
[Rodar Garra]
[Acção Y2]
]
[Euro Pallet]
[{Disposição $xyz$}
[{$x=?$}]
[{$y=?$}]
[{$z=?$}]
]
]
]
]
[Sistema de despacho
[Sensor de peso\\/contador]
[Tapete rolante\\de saída]
]
]
\end{forest}
\end{document}