1

I came across this page where they explain how to draw fancy arrows with shadows etc.

Fancy arrows with TikZ

However, in the example, the arrows are embedded in the text. I would like to draw it in the tikzfigure environment between nodes.

\begin{tikzpicture}
 \node[](a){};
 \node[right of=a,node distance=10cm](b){};

 \draw[ ??](a) -- (b);

\end{tikzpicture}

What is the correct syntax in the example?

1 Answers1

2

If you use the code from the accepted answer to Fancy arrows with TikZ, then note that the arrowstyle style takes an argument that determines the length of the arrow. Hence, if you have

\node [draw] (a) {A};
\node [draw,right=5cm of a] (b) {B};

so you know the distance between the nodes is 5cm, then you can use

\node [arrowstyle=5cm,right=0pt of a] {};

to get such an arrow starting at a, ending at b.


Addendum: The right of= syntax you used is considered deprecated, instead you should load the positioning library and use right=of, as I did above. See Difference between "right of=" and "right=of" in PGF/TikZ


If you don't know the exact distance, or you need to rotate it (i.e. if node b isn't straight right of a), then you can load the calc library and calculate distance and angle like this:

\path
 let
   \p1=(a2.south east), % start point
   \p2=(b2.north west), % end point
   \n1={veclen(\x2-\x1,\y2-\y1)}, % distance between start and end
   \n2={atan2(\y2-\y1,\x2-\x1)}   % angle between start and end
 in
  node [arrowstyle=\n1,
        right=0 of a2.south east,
        rotate=\n2,
        fading angle=\n2 % only  affects shadow
       ] {};

Note that the colour fading itself is not rotated, so that always goes from top to bottom. Note also that because this is a node, not a normal line path, you can only have straight lines, curved or kinked arrows are not possible.

enter image description here

\documentclass[svgnames,border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{
  fadings,
  shapes.arrows,
  shadows,
  positioning
}   

\tikzfading[name=arrowfading, top color=transparent!0, bottom color=transparent!95]

\tikzset{
  arrowfill/.style={
     top color=OrangeRed!20,
     bottom color=Red,
     general shadow={fill=black, shadow yshift=-0.8ex, path fading=arrowfading}
  },
  arrowstyle/.style={
     draw=FireBrick,
     arrowfill,
     single arrow,
     minimum height=#1,
     single arrow head extend=.4cm
   }
}


\begin{document}
\begin{tikzpicture}
 \node [draw] (a) {A};
 \node [draw,right=5cm of a] (b) {B};
 \node [arrowstyle=5cm,right=0pt of a]{};


 \node [draw,below=1cm of a] (a2) {A2};
 \node [draw,below right=3cm of a2] (b2) {B2};
 \node [arrowstyle=3cm,
        right=0 of a2.south east,
        rotate=-45,
        fading angle=-45 % only  affects shadow
       ] {};
\end{tikzpicture}
\end{document}
Torbjørn T.
  • 206,688