我只是在体验森林,我想有一个响应的孩子,而不是像下图所示的那样在一行中:
我想拆分 1 级的所有子级文本。我已经尝试过了QoS Modeling and Analysis\\in 5G Backhaul Networks
,但不起作用 :/ 只有在下一级时才有效。
\begin{figure}[htb]
\resizebox{\textwidth}{!}{%
\begin{forest}
% forest preamble: determine layout and format of tree
direction switch
[Service Function Chaining Solutions
[QoS Modeling and Analysis\\in 5G Backhaul Networks
[Thesis\#1
[Present multilayer model\\for 4G \& 5G networks]
[Propose SFC solutions\\ to create service chains]
]
]
[SFC avoid overloads
[Thesis\#2
[Study the effect of\\overloaded links]
[Propose architectures\\to classify the solutions]
[Propose algorithms\\to avoid overloads]
]
[Thesis\#3
[Study the effect of\\overloaded links]
]
]
[SFC avoid overloads in NS
[Thesis\#4
[Study the effect of\\overloaded links]
[Avoid link congestion\\in network slicing]
]
[Thesis\#5
[Study the effect of\\overloaded links]
[Avoid link congestion\\in network slicing]
]
]
[Demonstration
[Implementation
[Study the effect of\\overloaded links]
[Avoid link congestion\\in network slicing]
]
]
]
\end{forest}
}
\end{figure}
我使用以下配置:
\usepackage{forest}
\usepackage{enumerate}
\forestset{
direction switch/.style={
for tree={
if level=3{}{draw},
thick,
edge={thick},
if level=1{
child anchor=north,
edge path={
\noexpand\path [\forestoption{edge}] (!u.parent anchor) -- ++(0,-.5em) -| (.child anchor)\forestoption{edge label};
},
s sep+=.5em,
for descendants={
child anchor=west,
align=left,
edge path={
\noexpand\path [\forestoption{edge}] (!u.parent anchor) ++(1em,0) |- (.child anchor)\forestoption{edge label};
},
fit=band,
},
for tree={
parent anchor=south west,
anchor=mid west,
grow'=0,
if n children=0{}{
delay={
prepend={[,phantom, calign with current]}
}
},
before computing xy={
l=2em
},
},
before drawing tree={
x/.wrap pgfmath arg={##1}{.6*x()},
for children={
x/.wrap pgfmath arg={##1+1em}{.6*x()},
for children={
x/.wrap pgfmath arg={##1+2em}{.6*x()},
}
}
}
}{
if level=0{
parent anchor=south,
anchor=south,
}{},
},
},
}
}
答案1
嗯,你非常接近(我猜)你想要的结果——较低节点中的文本已经分成两行。同样的方式,你可以在树的第二层(甚至在根节点)中执行此操作。
无论如何,我付出了一些努力来将您的代码片段合并到一个完整的可编译文档中(称为 MWE:最小工作示例)。此时我forest
从头开始重写设置。
\documentclass[border=3.141592mm]{standalone}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
for tree={
draw,
font=\small\linespread{0.84}\selectfont,
calign=edge midpoint,
align=center,
if level =1{draw,
minimum height=5.6ex,
edge path={\noexpand\path[\forestoption{edge}]
(!u.south) -- ++ (0,-3mm) -| (.child anchor);}
}{},
if level>=1{grow'=0,
folder,
folder indent=4mm,
l sep=7mm,
s sep=1mm}{},
if level =2{draw, align=left}{},
if level>=3{draw=none,
text width=11em,
align=left}{},
}
%
[Service Function %\\ % delete first % to have text in two lines
Chaining Solutions
[QoS Modeling and Analysis\\
in 5G Backhaul Networks
[Thesis\#1
[Present multilayer model\\for 4G \& 5G networks]
[Propose SFC solutions\\ to create service chains]
]
]
[SFC avoid\\ overloads
[Thesis\#2
[Study the effect of\\overloaded links]
[Propose architectures\\to classify the solutions]
[Propose algorithms\\to avoid overloads]
]
[Thesis\#3
[Study the effect of\\ overloaded links]
]
]
[SFC avoid\\ overloads in NS
[Thesis\#4
[Study the effect of\\overloaded links]
[Avoid link congestion\\in network slicing]
]
[Thesis\#5
[Study the effect of\\overloaded links]
[Avoid link congestion\\in network slicing]
]
]
[Demonstration
[Implementation
[Study the effect of\\overloaded links]
[Avoid link congestion\\in network slicing]
]
]
]
\end{forest}
\end{document}
这就是你要找的吗?