2

I would like to draw a box including an arrow which is defined as Infographic Box with Arrow at this link. I would like to update the following figure to generate a top-to-bottom diagram.

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

enter image description here

Is there a way to update my boxes and make them look like the figure below.

enter image description here

1

1 Answer 1

4

The shapes.arrows library that comes with TikZ has an arrow box shape which you could try:

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

enter image description here

Note that you should use \tikzset instead of \tikzstyle.


Alternatively, you could draw the border of the nodes by hand or, in order to avoid repetition in your code, create a \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}

enter image description here

1
  • When I use rounded corners, the shape of arrow gets distorted. Is there a way to fix it?
    – ball_jan
    Commented Apr 23 at 2:22

You must log in to answer this question.

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