森林:文件夹上的垂直空间增长

森林:文件夹上的垂直空间增长

我想“动态”计算节点必须具有的垂直空间以避免重叠,并且最好将它们对齐,目前我有一个名为的样式,arrowed folder它几乎是 grow 样式的副本folder。但是,文件夹和我的都存在当文本“较大”时节点重叠的问题

\documentclass{article}
\usepackage[edges]{forest}
\usepackage{xcolor}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Forest arrowed folder edges

\forestset{
    declare dimen register=arrowed folder indent,
    arrowed folder indent=0.45em,
    arrowed folder/.style={
        parent anchor=-children last,
        anchor=parent first,
        calign=child,
        calign primary child=1,
        for children={
            child anchor=parent,
            anchor=parent first,
            edge={rotate/.option=!parent.grow},
            edge path'/.expanded={
                [
                    color=linecol,
                    rounded corners=2pt,
                    >={Stealth[length=6pt]},
                    line width=0.5pt,
                    ->
                ]
                ([xshift=\forestregister{arrowed folder indent}]!u.parent anchor) |- (.child anchor)
            },
        },
        after packing node={
            if n children=0{}{
                tempdiml=l_sep()-1*l("!1"),
                tempdims={-abs(max_s("","")-min_s("",""))-s_sep()},
                for children={
                    l+=tempdiml,
                    s+=tempdims()*(reversed()-0.5)*2,
                },
            },
        },
    }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\begin{forest}
    forked edges,
    for tree = {
        anchor = center,
        rectangle,
        if = {level == 0}{
            l sep = 10mm,
            outer color= red!176!green!171!blue!200,
            text width = 0.25\linewidth,
            for tree = {
                for children = {
                    grow'=0,
                    arrowed folder
                }
            }
        }{},
        if = {level == 1}{
            outer color= red!176!green!221!blue!255,
            text width = 0.20\linewidth,
        }{},
        if = {level == 2}{
            outer color= red!150!green!221!blue!175,
            text width = 0.15\linewidth
        }{},
    },
    [Bombas hidráulicas
        [Bombas de engranajes
            [Baja eficiencia volumétrica]
            [Pueden ser de engranaje externo o interno]
            [Precio asequible]
            [cilindrada fija]
        ]
        [Bombas de pistón
            [Tienen la mejor eficiencia volumétrica global]
            [Generan presiones elevadas]
            [Existen en montaje radial y montaje axial]
            [Precio alto]
        ]
        [Bombas de paletas
            [Rendimiento volumétrico bueno]
            [Silenciosas]
            [Precio más alto que las B.H. pero menos que las B.P.]
            [Son bombas frágiles]
        ]
        [Bombas de tornillo
            [Adecuadas para presiones muy altas]
            [Poco eficientes]
            [Propulsión axial]
        ]
    ]
\end{forest}
\end{document}

在此处输入图片描述

为了修改垂直空间,我正在调整s值,但这不是一个很好的解决方案

after packing node={
    if n children=0{}{
        tempdiml=l_sep()-1*l("!1"),
        tempdims={-abs(max_s("","")-min_s("",""))-s_sep()},
        for children={
            l+=tempdiml,
            s+=tempdims()*(reversed()-0.5)*5,
        },
    },
},

在此处输入图片描述

我知道改变顺序有帮助,但我该怎么办,例如,如果一个节点上只有一个大孩子?

在此处输入图片描述 在此处输入图片描述

相关内容