本问题是这个,并依赖于那里给出的答案。以下是生成下图的代码。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary {calc, graphs, graphdrawing}
\usegdlibrary {trees}
\usegdlibrary{layered}
\begin{document}
\begin{tikzpicture}[
> = stealth,
every node/.append style = {font = \sf\vphantom{gf}},
connect/.style = {to path = {(\tikztostart) -- ($(\tikztostart)!.5!(\tikztostart |- \tikztotarget)$) -| (\tikztotarget)}},
connectEffects/.style = {to path = {(\tikztostart) -- node[pos = 0.5, fill = white]{effects} ($(\tikztostart)!.65!(\tikztostart |- \tikztotarget)$) -| (\tikztotarget)}},
connectSubjects/.style = {to path = {(\tikztostart) -- node[pos = 0.5, fill = white]{subjects} ($(\tikztostart)!.65!(\tikztostart |- \tikztotarget)$) -| (\tikztotarget)}},
connectFactors/.style = {to path = {(\tikztostart) -- node[pos = 0.5, fill = white]{block factors} ($(\tikztostart)!.65!(\tikztostart |- \tikztotarget)$) -| (\tikztotarget)}},
connectSize/.style = {to path = {(\tikztostart) -- node[pos = 0.5, fill = white]{block size} ($(\tikztostart)!.65!(\tikztostart |- \tikztotarget)$) -| (\tikztotarget)}},
]
\graph [
layered layout,
nodes = {draw, fill = white},
edge quotes = {fill = white},
level 1/.style = {level distance = 1.5 cm},
level 2/.style = {level distance = 1.5 cm},
level 3/.style = {level distance = 1.5 cm},
level 4/.style = {level distance = 1.5 cm},
level 5/.style = {level distance = 0.75 cm},
level 6/.style = {level distance = 0.75 cm},
level 7/.style = {level distance = 0.75 cm},
level 8/.style = {level distance = 0.75 cm},
sibling distance = 2 cm
]{
experiment ->[connectEffects] {
fixed ->[connectSubjects] {
homogeneous -> [minimum layers = 4]
CRD ->
CRFD ->
CRSP,
heterogeneous ->[connectFactors] {
one ->[connectSize] {
large -> {
RCB ->
GCB ->
RCBF ->
RBSP
},
small ->
PBIB or BTIB ->
BIB
},
two -> [minimum layers = 2]
LSD
}
},
mixed
}
};
\end{tikzpicture}
\end{document}
我想将级别之间的距离设置为 1.5 厘米,直到级别 5,然后切换到 0.75 厘米。这似乎在级别 6 之后失败了。
一个附属问题:我想让定义四个连接器的代码connectEffects/.style =
更加通用和简洁。