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?

  • arrows in the answers in your link are nodes and they can not be simple draw as lines. – Zarko Apr 26 '18 at 10:53
  • I'm not sure if I understand your comment. I would like to know how to draw an arrow between two nodes with the given style in the link. – Adam Gosztolai Apr 26 '18 at 10:56
  • arrows (for example from arrows.meta) as lines yes, as nodes no (only if node fit this two coordinates, however, in this you limited quite limited – Zarko Apr 26 '18 at 11:03
  • Could you post a MWE so we can see what you want to achieve precisely ? – BambOo Apr 26 '18 at 11:04
  • I cannot, because I don't have a working example. – Adam Gosztolai Apr 26 '18 at 12:24
1

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}

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.