我正在尝试复制下图
这很简单,但到目前为止,我已经有了代码中显示的框和链接
\documentclass[tikz,12pt]{standalone}
\usetikzlibrary{calc,positioning,backgrounds,arrows.meta}
\usepackage{forest}
\pagestyle{empty}
\begin{document}
\begin{forest}
for tree={
child anchor=west,
parent anchor=east,
grow=east,
draw,
anchor=west,
edge path={
\noexpand\path[\forestoption{edge}]
(.child anchor) -| +(-5pt,0) -- +(-5pt,0) |-
(!u.parent anchor)\forestoption{edge label};
},
}
[Rentas vitalicias
[Capital reservado
[Todo [Muerte antes del retiro] [Muerte antes y despu\'es del retiro]
]
[Mitad [Muerte antes del retiro] [Muerte antes y despu\'es del retiro]
]
]
[Capital cedido
]
]
]
]
\end{forest}
\end{document}
其结果:
有什么建议可以使它更类似于第一张图片,具有更长的线条并且没有方框?
在此先感谢您的时间。
答案1
\documentclass[tikz,12pt]{standalone}
%\usetikzlibrary{calc,positioning,backgrounds,arrows.meta}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={
child anchor=west,
grow=east,
anchor=west,
edge path={
\noexpand\path[\forestoption{edge}]
(.child anchor) +(-5pt,-6pt) -- +(-5pt,6pt) --([xshift=-5pt]!s.anchor)
(!u.parent anchor)\forestoption{edge label};
},
}
[Rentas vitalicias,s sep=1cm
[Capital reservado
[Todo,text width=3em
[Muerte antes del retiro]
[Muerte antes y despu\'es del retiro]
]
[Mitad,text width=3em
[Muerte antes del retiro]
[Muerte antes y despu\'es del retiro]
]
]
[Capital cedido
]
]
]
]
\end{forest}
\end{document}
更新:改变了两个节点的最小文本宽度和垂直间距,感谢 Alan Munn!