1

I am attempting to adapt a solution by Zarko to Forest latex how to go to next line in node child for a report I am writing. I like the forest diagram style but I am struggling how to position an arrow underneath the forest diagram as tikz is new to me. This is how it currently looks (note: I haven't edited the sub-text from the linked question as I am trying to format it first):

enter image description here

I am not happy with the arrow as it is for two reasons:

1 - My method of positioning the arrow using

\node (a) at (1, 0) {};
\node[single arrow,
        draw,
        left color=white,
        right color=black,
        minimum width = 8pt,
        single arrow head extend=6pt,
        minimum height=20cm,
        below=7.5cm,
        at=(a.south),
        ] (b) {\textcolor{white}{\small\textbf{Increasing complexity}}};

is making it difficult to position the left-end of the arrow to the to west part of the box entitled Natural evolution and the right-end of the arrow to the east part of the box entitled De novo design. How can the arrow extend on the x-axis between the west of Natural evolution and the east of De novo design please?

2 - The method of positioning on the y-axis is also not adequate as I am having to do it manually with the options below=7.5cm,at=(a.south) after setting a \node at (1, 0). Is there a better way to position it say 10pt (or any value that can be changed) beneath one of the textboxes (that can be manually changed to the textbox that is the lowest)?

I have been reading about setting positions relative and moving them with constructs such as \node (node.east) ++(x,y) {} but would appreciate some advice on the best way to go about this so I can learn from it please.

MWE:

\documentclass[border=0pt]{standalone}

\usepackage{tikz}
\usepackage{forest}
\useforestlibrary{edges}
\usetikzlibrary{shapes,arrows,backgrounds,shadings}

\newcommand*\Denovo{\textit{De novo}}

\begin{document}

\begin{forest}
for tree={
    draw,
    grow=south,
    font=\small\linespread{0.84}\selectfont,
    calign=edge midpoint,
    align=center,
    if level=0{%
        draw,,
        font=\bfseries,
        minimum width=18ex,
        minimum height=5.6ex,
        l sep=6mm,
        }{},
    if level =1{%
        draw,
        font=\bfseries,
        minimum width=18ex,
        minimum height=5.6ex,
        edge path={\noexpand\path[\forestoption{edge}]
        (!u.south) -- ++ (0,-3mm) -| (.child anchor);}
        }{},
    if level>=1{%
        grow'=0,
        folder,
        folder indent=4mm,
        l sep=7mm,
        s sep=1mm}{},
    if level =2{%
        draw,
        align=left}{},
    if level>=3{%
        draw=none,
        text width=11em,
        align=left}{},
}
%
[Enzyme design
    [Natural evolution, name=natev
        [Thesis\#1
            [Present multilayer model\\for 4G \& 5G networks]
            [Propose SFC solutions\\ to create service chains]
        ]
        [Thesis\#2
            [Present multilayer model\\for 4G \& 5G networks]
            [Propose SFC solutions\\ to create service chains]
        ]
    ]
    [Directed evolution
        [Thesis\#2
            [Study the effect of\\overloaded links]
            [Propose architectures\\to classify the solutions]
            [Propose algorithms\\to avoid overloads]
        ]
        [Thesis\#3
           [Study the effect of\\ overloaded links]
        ]
    ]
    [Rational design
        [Thesis\#4
            [Study the effect of\\overloaded links]
            [Avoid link congestion\\in network slicing]
        ]
        [Thesis\#5
            [Study the effect of\\overloaded links]
            [Avoid link congestion\\in network slicing]
        ]
    ]
    [\Denovo\ design,name=denovo
        [Implementation
            [Study the effect of\\overloaded links]
            [Avoid link congestion\\in network slicing]
        ]
    ]
]
\node (a) at (1, 0) {};
\node[single arrow,
        draw,
        left color=white,
        right color=black,
        minimum width = 8pt,
        single arrow head extend=6pt,
        minimum height=20cm,
        below=7.5cm,
        at=(a.south),
        ] (b) {\textcolor{white}{\small\textbf{Increasing complexity}}};
\end{forest}
\end{document}
0

2 Answers 2

1

Hm, like this:

enter image description here

Arrow length is calculated as distance between natev. west (name of "Natural evolution" node) and denovo.east (name of De novo design! node). For positioning at bottom of tree is added to the last node in the first name natevbottom:

\documentclass[border=3pt]{standalone}

\usepackage{tikz}
\usepackage{forest}
\useforestlibrary{edges}
\usetikzlibrary{calc,
                shadings, shapes}

\newcommand*\Denovo{\textit{De novo}}

\begin{document}

\begin{forest}
for tree={
    draw,
    grow=south,
    font=\small\linespread{0.84}\selectfont,
    calign=edge midpoint,
    align=center,
    if level=0{%
        draw,,
        font=\bfseries,
        minimum width=18ex,
        minimum height=5.6ex,
        l sep=6mm,
        }{},
    if level =1{%
        draw,
        font=\bfseries,
        minimum width=18ex,
        minimum height=5.6ex,
        edge path={\noexpand\path[\forestoption{edge}]
        (!u.south) -- ++ (0,-3mm) -| (.child anchor);}
        }{},
    if level>=1{%
        grow'=0,
        folder,
        folder indent=4mm,
        l sep=7mm,
        s sep=1mm}{},
    if level =2{%
        draw,
        align=left}{},
    if level>=3{%
        draw=none,
        text width=11em,
        align=left}{},
}
%
[Enzyme design
    [Natural evolution, name=natev
        [Thesis\#1
            [Present multilayer model\\for 4G \& 5G networks]
            [Propose SFC solutions\\ to create service chains]
        ]
        [Thesis\#2
            [Present multilayer model\\for 4G \& 5G networks]
            [Propose SFC solutions\\ to create service chains,
             name=natevbottom]
        ]
    ]
    [Directed evolution
        [Thesis\#2
            [Study the effect of\\overloaded links]
            [Propose architectures\\to classify the solutions]
            [Propose algorithms\\to avoid overloads]
        ]
        [Thesis\#3
           [Study the effect of\\ overloaded links]
        ]
    ]
    [Rational design
        [Thesis\#4
            [Study the effect of\\overloaded links]
            [Avoid link congestion\\in network slicing]
        ]
        [Thesis\#5
            [Study the effect of\\overloaded links]
            [Avoid link congestion\\in network slicing]
        ]
    ]
    [\Denovo\ design,name=denovo
        [Implementation
            [Study the effect of\\overloaded links]
            [Avoid link congestion\\in network slicing]
        ]
    ]
]
\path   let \p1 = (natev.west),
            \p2 = (denovo.east),
            \n1 = {veclen(\y2-\y1,\x2-\x1)} in
        node [single arrow, single arrow head extend=6pt,
              draw,
              left color=white,right color=black,
              font=\bfseries, text=white,
              minimum width = 8pt,
              minimum height=\n1,
              below=8pt, right] at (natev.west |- natevbottom.south)    
              {Increasing complexity};
\end{forest}
\end{document}
1

Nodes which span over a certain range of can be created with the fit library. This example defines two points that are fitted, (L) and (R), and then fits the arrow. As illustrated, you can use xshift and yshift in order to change the location of these points. Notice also that one can use the text and font keys to control the font of the node.

\documentclass[border=0pt]{standalone}

\usepackage{tikz}
\usepackage{forest}
\useforestlibrary{edges}
\usetikzlibrary{shapes,arrows,backgrounds,shadings,fit}

\newcommand*\Denovo{\textit{De novo}}

\begin{document}

\begin{forest}
for tree={
    draw,
    grow=south,
    font=\small\linespread{0.84}\selectfont,
    calign=edge midpoint,
    align=center,
    if level=0{%
        draw,,
        font=\bfseries,
        minimum width=18ex,
        minimum height=5.6ex,
        l sep=6mm,
        }{},
    if level =1{%
        draw,
        font=\bfseries,
        minimum width=18ex,
        minimum height=5.6ex,
        edge path={\noexpand\path[\forestoption{edge}]
        (!u.south) -- ++ (0,-3mm) -| (.child anchor);}
        }{},
    if level>=1{%
        grow'=0,
        folder,
        folder indent=4mm,
        l sep=7mm,
        s sep=1mm}{},
    if level =2{%
        draw,
        align=left}{},
    if level>=3{%
        draw=none,
        text width=11em,
        align=left}{},
}
%
[Enzyme design
    [Natural evolution, name=natev
        [Thesis\#1
            [Present multilayer model\\for 4G \& 5G networks]
            [Propose SFC solutions\\ to create service chains]
        ]
        [Thesis\#2
            [Present multilayer model\\for 4G \& 5G networks]
            [Propose SFC solutions\\ to create service chains]
        ]
    ]
    [Directed evolution
        [Thesis\#2
            [Study the effect of\\overloaded links]
            [Propose architectures\\to classify the solutions]
            [Propose algorithms\\to avoid overloads]
        ]
        [Thesis\#3
           [Study the effect of\\ overloaded links]
        ]
    ]
    [Rational design
        [Thesis\#4
            [Study the effect of\\overloaded links]
            [Avoid link congestion\\in network slicing]
        ]
        [Thesis\#5
            [Study the effect of\\overloaded links]
            [Avoid link congestion\\in network slicing]
        ]
    ]
    [\Denovo\ design,name=denovo
        [Implementation
            [Study the effect of\\overloaded links]
            [Avoid link congestion\\in network slicing]
        ]
    ]
]
%\node (a) at (1, 0) {};
\path ([yshift=-2em]current bounding box.south west) coordinate (L)
    ([yshift=-2em,xshift=-3em]current bounding box.south east) coordinate (R)
node[single arrow,
        draw,
        fit={(L)(R)},
        left color=white,
        right color=black,
        single arrow head extend=6pt,
        text=white,
        text height=12pt,
        text depth=4pt,
        font=\small\bfseries\sffamily,
        ] (b) {Increasing complexity};
\end{forest}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .