3

Tikz has a special shape called "arrow box". It is a box with arrows going out of it directly. But how can we change the direction of arrows in this shape? In fact, I need to draw an "arrow box" with curved arrows, something like what is shown in the attached picture.

enter image description here

Does anyone know how it is possible? By the way, I don't need the other part of this picture. Only the arrow box is my question. Thank you.

  • Related: tex.stackexchange.com/questions/18471/… – Ignasi Jun 4 '15 at 14:49
  • 1
    @Ignasi can you clarify how that answer you linked is related to bending arrows? – aeroNotAuto Jun 4 '15 at 14:55
  • @aeroNotAuto You're right, my comment was not clear. The only way I know for drawing curved empty arrows is what is suggested in linked answer: a preaction which, although serves for straight lines, not always does it for curved ones. Even more, the junction between arrow and box is also difficult. I hope somebody shows us a solution. – Ignasi Jun 4 '15 at 16:24
5

This solution is a bit of a hack for the top arrow. Basically any arrow that starts orthogonal to the node's border will have no problem, but diagonal arrows will "break" the make-believe, by appearing like this:

figure 1

The best way I could think of to deal with this is by automatically adding another node inside which border is white and is positioned on the foreground, thus covering the extra piece.

figure 2

Things to improve:

  • This is currently done manually anchoring the node and subtracting the other lengths so that it fits perfectly inside, but I'd like to make it automatic.
  • And even better would be to add a "stretchable" path that adapts to the main node (if you add more words for example).
  • Also, at this moment, I haven't succeeded in making it work with an edge or to, but it shouldn't be that hard.

I'll edit the answer if I find a way.

Output

figure 3

Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}

\usetikzlibrary{calc, arrows.meta, decorations.markings,backgrounds}

\pgfdeclarelayer{main}
\pgfdeclarelayer{fg}
\pgfsetlayers{main,fg}

\tikzset{
    rect/.style={draw, line width=.3mm, rectangle, inner sep=0, minimum height=2cm, minimum width=5cm, fill=white,
        append after command={\pgfextra{\begin{pgfonlayer}{fg}\node[draw=white, line width=1.5mm, minimum height=1.82cm, minimum width=4.82cm, anchor=north west] at ($(\tikzlastnode.north west)+(\mybor,-\mybor)$) {};\end{pgfonlayer}}}
    },
    warr/.style={draw=black, double=white, line width=1pt, double distance=1mm, shorten >=10.9pt, rounded corners=#1,
        decoration={markings,mark=at position 1 with {\arrow{Triangle[open,length=12pt, width=12pt,line width=1.1pt]}}, 
            mark=at position 0 with {\arrow{Turned Square}}},
        preaction={decorate},
        postaction={draw,white, line width=1mm,shorten >=6pt, shorten <=2pt},
    },
}

\begin{document}
\begin{tikzpicture}
    \coordinate (a) at (-5,1);
    \coordinate (b) at (-1,-3);

    \node[rect] (na) at (0,0) {This is a very fancy node};

    \draw[warr=2cm] ($(na.south west)!.8!(na.south east)$) |- (b);
    \draw[warr=2cm] ($(na.north west)!.3!(na.north east)+(0,-1mm)$) -- ++(-2cm,2.5cm) -- (a);
\end{tikzpicture}
\end{document}

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.