森林——如何在 3 级和 4 级创建自定义边缘路径

森林——如何在 3 级和 4 级创建自定义边缘路径

在尝试回答问题 [https://tex.stackexchange.com/questions/567434/tikz-tree-diagram-classification-with- functional-levels] 时,我卡在第 3 级和第 4 级--

如何从 C1 开始获得正确的结构设置——类似于参考链接中显示的内容

摘录链接

在此处输入图片描述

其中 C1 = 混合,C11 = MEMS,C12 = 引文,依此类推向东

平均能量损失

\documentclass{article}
\usepackage{geometry}
\usepackage[edges]{forest}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{shadows}

\begin{document}
    \tikzset{
    my node style/.style={
        font=\small,
        top color=white,
        bottom color=blue!25,
        rectangle,
        rounded corners,
        minimum width=1em, text width=2em,
        draw=blue!75,
        very thick,
        align=center,
        }
    }
    \forestset{
    my tree style/.style={
        for tree={
            my node style, 
            grow=east, anchor=west, forked edge, 
%           calign=first, 
            reversed=true,
            edge={ultra thick}
            },
        where level=2{
        inner color=green!75,
        outer color=green,
    parent anchor=south east,
    for descendants={
%       folder,
    child anchor=west,
    parent anchor=south west,
    anchor=south west,
color=red!75,}}{}
        }
    }
\begin{forest}
    my tree style
    [X
        [A
            [A1]
            [A2]
            [A3]
            [A4]
        ]
        [B
            [B1]
            [B2]
            [B3]
            [B4]
            [B5]
        ]
        [C
            [C1,
                [C11
                [C12]]
                ]
            [C2]
            [C3]]]
\end{forest}
\end{document}

输出

在此处输入图片描述

答案1

作为起点...

\documentclass[margin=3.14159]{standalone}
\usepackage[T1]{fontenc}
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta,
                shadows}

\begin{document}
    \begin{forest}
for tree={
% node
    draw, rounded corners,% here you can insert your definition
% tree
    grow=0,
    forked edge,    % for forked edge
    s sep = 3mm,    % "sibling" distance
    l sep = 6mm,    % "level" distance
 fork sep = 2.5mm,  % distance from parent to branching point
tier/.option=level, % for aligning nodes to levels
% edge
    edge = {-Straight Barb, semithick},
% level styles
if level>= 2{s sep = 4mm}{s sep = 1mm}, % <---
if level>= 3{child anchor=west,         % <---
             edge path={\noexpand\path[\forestoption{edge}]
                (!u.south) |- (.child anchor);} 
             }{},
        } % end of `for tree`
[X
    [A
        [A1]
        [A2]
        [A3]
        [A4]
    ]
    [B, fit=band, before computing xy={s/.average={s}{siblings}}
        [B1]
        [B2]
        [B3]
        [B4]
        [B5]
    ]
    [C
        [C1,
            [C11
                [C12]
                [,phantom] % <---
            ]
            [,phantom]     % <---
        ]
        [C2]
        [C3]
    ]
]
    \end{forest}
\end{document}

在此处输入图片描述

相关内容