1

While attempting a question [https://tex.stackexchange.com/questions/567434/tikz-tree-diagram-classification-with-functional-levels] I got stuck at level 3 and 4--

How do I get the correct structure setup from C1 onwards-- similar to what is shown in the reference link

Extract of link

enter image description here

where C1 =Hybrid, C11=MEMS, C12=citation and so on going east

MWE

\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}

Output

enter image description here

1

As starting point ...

\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}

enter image description here

3
  • --do let me know if there is way to improve the symmetry / alignment of X with reference to ABC – js bibra Oct 22 '20 at 1:20
  • 1
    @jsbibra, see edited answer: now [B, fit=band, before computing xy={s/.average={s}{siblings}} – Zarko Oct 22 '20 at 2:23
  • methinks you are reading a different book for forest documentation -- haha – js bibra Oct 22 '20 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.