考虑以下代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{forest}
\title{Bla}
\author{John Doe}
\date{April 2020}
\begin{document}
\maketitle
\begin{forest}
for tree={
grow=east,
parent anchor=east,
child anchor=west,
align=center,
l=1em, l sep+=0em,anchor=base west,inner sep=0.1pt,outer sep=0pt,
edge path={
\noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(5pt,0) |- (.child anchor)\forestoption{edge label};
},
for root={
parent anchor=east,
},
}
[Main BLA,rotate=90,child anchor=north, parent anchor=south, anchor=center
[Quebec1234
[Romeo
]
[Sierra
]
]
[Alpha123
[India12345]
[Foxtrot,parent anchor=0
[Golf12345,edge path={
\noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) |- +(50pt,0pt) |- (.child anchor)\forestoption{edge label};
},before drawing tree={x+=44pt,y+=0pt}]
[Hotel1234567890,edge path={
\noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) |- +(50pt,0pt) |- (.child anchor)\forestoption{edge label};
},before drawing tree={x+=44pt,y+=0pt}]
]
[Echo123456]
[Delta12345]
[Charlie123]
[Bravo12345]
]
]
\end{forest}
\end{document}
结果如下:
我想减少节点Echo123456
和Foxtrot
以及和India12345
之间的空白(垂直)空间Foxtrot
。我知道s sep
,但我不确定如何将其仅应用于Foxtrot
。例如,当我将其设置为节点时Foxtrot
,它将减少节点Hotel1234567890
和的空间Golf12345
。相反,如果我将其设置为级别Alpha123
,则所有子级都会受到影响(而不仅仅是Foxtrot
)。
期望的结果:
答案1
使用forked edge
并在“Foxtrot”节点后添加坐标顶点:
\documentclass{article}
\usepackage[edges]{forest} % added option
\begin{document}
\begin{forest}
for tree={
grow=east,
anchor=west,
% edges
forked edge, % for forked edge
s sep = 1mm, % added
l sep = 6mm, % changed
fork sep = 3mm, % added distance from parent to branching point
}
[Main BLA, rotate=90,anchor=center
[Quebec1234
[Romeo]
[Sierra]
]
[Alpha123
[India12345]
[Foxtrot,
[,coordinate % <--- inserted
[Golf12345]
[Hotel1234567890]
]
]
[Echo123456]
[Delta12345]
[Charlie123]
[Bravo12345]
]
]
\end{forest}
\end{document}
正如您所看到的,删除了 MWE 中使用的所有边缘代码。希望结果接近您想要的结果: