当我使用以下代码时
\documentclass{article}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
for tree={
grow'=east,
anchor=west,
font=\itshape,
forked edge,
fork sep = 2mm,
l sep=4mm,
s sep=2mm,
},
s sep=2mm,
delay={ where content={}{coordinate}{}, },
[XXX-root,
[ % 1
[ % 2
[XXX-children-A
[XXX-children-B]
[XXX-children-C]
]
[XXX-children-D]
]
[ % 3
[XXX-children-E]
[XXX-children-F
[XXX-children-G]
[ % 4
[XXX-children-H]
[XXX-children-I]
]
]
]
]
[ % 5
[ % 6
[XXX-children-J]
[XXX-children-K]
]
[ % 7
[XXX-children-L]
[XXX-children-M
[XXX-children-N]
[ % 8
[XXX-children-O]
[ % 9
[XXX-children-P]
[ % 10
[ % 11
[XXX-children-Q]
[XXX-children-S]
]
[ % 12
[XXX-children-T]
[XXX-children-U]
]
]
]
]
]
]
]
]
\end{forest}
\end{document}
一切正常。但是,如果我在以下代码中更改节点中的文本
\documentclass{article}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
for tree={
grow'=east,
anchor=west,
font=\itshape,
forked edge,
fork sep = 2mm,
l sep=4mm,
s sep=2mm,
},
s sep=2mm,
delay={ where content={}{coordinate}{}, },
[Nymphalidae,
[ % 1
[ % 2
[Limenitidinae
[Neptini]
[Limenitidini]
]
[Heliconiinae]
]
[ % 3
[Apaturinae]
[Nymphalinae
[Nymphalini]
[ % 4
[Junoniini]
[Melitaeini]
]
]
]
]
[ % 5
[ % 6
[Libytheinae]
[Danainae]
]
[ % 7
[Charaxinae]
[Satyrinae
[Elymniini]
[ % 8
[Coenonymphini]
[ % 9
[Ypthimini]
[ % 10
[ % 11
[Melanargiini]
[Satyrini]
]
[ % 12
[Maniolini]
[Erebiini]
]
]
]
]
]
]
]
]
\end{forest}
\end{document}
我收到错误消息!尺寸太大。\pgf@x
如果我将空节点 11 和 12 更改为包含一个或多个字符的节点,则一切正常。这非常令人困惑,因为两段代码之间的唯一区别是每个节点中的文本。
答案1
我不知道为什么会出现这个错误。但是,使用坐标的目的似乎是为了避免间隙。这里有一个也可以避免间隙的解决方法:用一些短的水平线段替换空节点。
\documentclass{article}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
for tree={
grow'=east,
anchor=west,
font=\itshape,
forked edge,
fork sep = 2mm,
l sep=4mm,
s sep=2mm,
},
s sep=2mm,
delay={ where content={}{outer sep=0pt,inner sep=0pt,
append after command={(\tikzlastnode.west) edge (\tikzlastnode.east)}}{}, },
[Nymphalidae,
[ % 1
[ % 2
[Limenitidinae
[Neptini]
[Limenitidini]
]
[Heliconiinae]
]
[ % 3
[Apaturinae]
[Nymphalinae
[Nymphalini]
[ % 4
[Junoniini]
[Melitaeini]
]
]
]
]
[ % 5
[ % 6
[Libytheinae]
[Danainae]
]
[ % 7
[Charaxinae]
[Satyrinae
[Elymniini]
[ % 8
[Coenonymphini]
[ % 9
[Ypthimini]
[ % 10
[ % 11
[Melanargiini]
[Satyrini]
]
[ % 12
[Maniolini]
[Erebiini]
]
]
]
]
]
]
]
]
\end{forest}
\end{document}