如何使用 tikz 创建带箭头的信息图表框

如何使用 tikz 创建带箭头的信息图表框

我想画一个框,其中包含一个箭头,该箭头定义Infographic Box with Arrow此链接。我想更新下图以生成从上到下的图表。

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{shapes.geometric, arrows}

\begin{document}
\begin{tikzpicture}[font=\small, node distance=2cm]
\tikzstyle{block} = [rectangle, draw, text width=12cm, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']

\node [block] (step1) {Alpha process};
\node [block, below of=step1] (step2) {Beta analysis};
\node [block, below of=step2] (step3) {Gamma results};

\path [line] (step1) -- (step2);
\path [line] (step2) -- (step3);
\end{tikzpicture}
\end{document}

在此处输入图片描述

有没有办法更新我的盒子并使它们看起来如下图所示。

在此处输入图片描述

答案1

shapes.arrowsTi 自带的库Z 有一个arrow box形状你可以尝试一下:

\documentclass[tikz, border=10pt]{standalone}
\usetikzlibrary{shapes.arrows}

\begin{document}
\begin{tikzpicture}
\tikzset{
    font=\small, 
    node distance=2cm,
    block/.style={
        arrow box, 
        draw, 
        text width=12cm, 
        text centered, 
        minimum height=4em,
        arrow box arrows={south:0.5cm}
    },
    last block/.style={
        block,
        arrow box arrows={south:0cm}
    }
}

\node[block] (step1) {Alpha process};
\node[block, below of=step1] (step2) {Beta analysis};
\node[last block, below of=step2] (step3) {Gamma results};

\end{tikzpicture}
\end{document}

在此处输入图片描述

请注意,您应该使用\tikzset而不是\tikzstyle


或者,您可以手动绘制节点的边框,或者为了避免代码重复,创建一个\pic

\documentclass[tikz, border=10pt]{standalone}
\usetikzlibrary{shapes.arrows}

\begin{document}
\begin{tikzpicture}
\tikzset{
    font=\small, 
    node distance=2cm,
    pics/box with arrow/.style={
        code={
            \node[pic actions, text centered] (-node) {#1};
            \draw[rounded corners] 
                ([xshift=-0.25em]-node.south) -| (-node.north west) -| 
                (-node.south east) -- ([xshift=0.25em]-node.south);
            \draw ([xshift=-0.25em]-node.south) |- ++(-0.25em,-0.5em) --
                ++(0.5em,-0.5em) -- ++(0.5em,0.5em) -| ++(-0.25em,0.5em);
        }
    },
    pics/box without arrow/.style={
        code={
            \node[pic actions, text centered] (-node) {#1};
            \draw[rounded corners] 
                (-node.south east) rectangle (-node.north west);
        }
    }
}

\pic[text width=12cm, minimum height=4em] 
    (step1) {box with arrow={Alpha process}};

\pic[below of=step1-node, text width=12cm, minimum height=4em] 
    (step2) {box with arrow={Beta analysis}};

\pic[below of=step2-node, text width=12cm, minimum height=4em] 
    (step3) {box without arrow={Gamma results}};

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容