在 TikZ 森林绘图上定位箭头形状

在 TikZ 森林绘图上定位箭头形状

我正在尝试适应Zarko 的解决方案Forest Latex 如何转到节点子节点中的下一行我正在写一份报告。我喜欢图表样式,但我不知道如何在图表forest下方放置箭头,这对我来说是新事物。这是它目前的样子(注意:我没有编辑链接问题的子文本,因为我正在尝试先对其进行格式化):foresttikz

在此处输入图片描述

我对这个箭头不太满意,原因有二:

1-我的定位箭头的方法

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

很难将箭头的左端定位到west框的自然进化箭头的右端指向east标有从头设计west。请问自然进化和east从头设计之间的 x 轴上的箭头如何延伸?

2 - 在 y 轴上定位的方法也不够充分,因为我必须below=7.5cm,at=(a.south)在设置 a 后\node使用选项手动执行此操作(1, 0)。有没有更好的方法将它定位10pt在其中一个文本框下方(可以手动更改为最低的文本框)?

我一直在阅读有关设置相对位置并使用诸如此类的结构来移动它们的文章,\node (node.east) ++(x,y) {}但我希望得到一些关于如何最好地解决这一问题的建议,以便我可以从中学习。

梅威瑟:

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

答案1

嗯,像这样:

在此处输入图片描述

箭头长度计算为natev. west(“自然进化”节点的名称) 和denovo.east(De novo design! 节点的名称) 之间的距离。为了定位在树的底部,将其添加到第一个名称中的最后一个节点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}

答案2

可以使用库创建跨越一定范围的节点fit。此示例定义了两个适合的点,(L)(R),然后适合箭头。如图所示,您可以使用xshiftyshift来更改这些点的位置。还请注意,可以使用textfont键来控制节点的字体。

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

在此处输入图片描述

相关内容