5

I was wondering if it's possible to create an arrow like in the following figure using TikZ: enter image description here

I have found thick arrows here and here, but I don't see how that code can be easily changed to reproduce the arrow I want. Also, it would be great if I don't have to "draw" the arrow but I can use the same type of command that is normally used for arrows in tikz. For instance, it would be nice to do:

 \draw[style=custom, line width=5ex]  (a) to[in=135,out=45] (b);
aaragon
  • 3,041

2 Answers2

2

Maybe this help as a starting point.

\documentclass[margin=3mm]{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[line width=0.5mm, line cap=round] \draw (0.5,2)--(0.75,2.5)--(1.5,2.25)--++(190:0.4)coordinate(B); \draw (0.5,2)--++(20:0.3)coordinate(A); \path(A) edge bend left=50; \path(B) edge bend left=50; \end{tikzpicture}

\end{document}

enter image description here

  • Thanks for your answer. Using draw was exactly what I wanted to avoid because every single time you change the length/direction of the arrow, all these lines have to be updated. It would be great to put this together into a new type of arrow. Do you think that's even remotely possible? – aaragon Oct 15 '20 at 09:42
  • Have you thought of using the pic command? –  Oct 15 '20 at 11:21
  • No because it should be with other tikz commands. The arrow is just but a very small component of a much larger tikz diagram. – aaragon Oct 15 '20 at 11:22
  • @aaragon Probably specifying what uses you might have for this new arrow might help us determine the best solution for your case because let's that you can achieve the same result: a one-time solution and a more dynamic command will both work but one might be better than the other in a certain situation. – Alenanno Oct 15 '20 at 12:57
  • @Alenanno arrows of this kind can have a myriad of applications. Just run an image search in google for curved thick arrow and you'll see what I mean. It would be great to have this capability with tikz. – aaragon Oct 15 '20 at 13:59
  • @aaragon I'm fully aware it can have many applications, that's why I was wondering about what yours would be. Does it need to curve like that or straight is fine? Do you want to be able to edit the fill color and/or the stroke color? Are these "nice to have" or a must? Etc. – Alenanno Oct 15 '20 at 14:04
  • @Alenanno in my particular application I need the arrow just as shown, filled in white and with think black lines. The only thing I need is to change the length and orientation depending on where I use it. But of course it would be fantastic to change the fill color, the curvature angle (even to have the tappered part with straight lines). – aaragon Oct 15 '20 at 15:08
2

This is my take on it, it sets a new style custarr that you can just add to any \draw command. You can set the stroke color and the fill to whatever you like, see the code below for examples.

Not yet supported / to-do features

  • Curving: the arrow will not work if you try to add an arc or to[out= <angle>, in= <angle>]. I'm fairly new to this type of path construction so I'll let you know when I am able to implement this.

Output

enter image description here

Code

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

\usetikzlibrary{decorations}

\pgfdeclaredecoration{newarrow}{initial}{ \state{initial}[% switch if less than=\pgfdecoratedpathlength/1 to final, %% (1) width=\pgfdecoratedpathlength/2, %% (2) next state=final ] {% \pgfsetfillcolor{white} \pgfsetstrokecolor{black} \pgfsetmiterjoin \pgfsetmiterlimit{12} % arrow start corner < \pgfmathsetmacro\onethird{\pgfdecoratedpathlength/2*1.5} \pgfmathsetmacro\arrowhead{\pgfdecoratedpathlength/7} \pgfmathsetmacro\arrowspread{\arrowhead/2} \pgfmoveto{\pgfpoint{14pt}{0pt}} % was 1pt with no miter limit \pgflineto{\pgfpoint{\onethird}{\arrowspread}} \pgflineto{\pgfpoint{\onethird}{\arrowhead}} \pgflineto{\pgfpoint{\pgfdecoratedpathlength-3pt}{0pt}} \pgflineto{\pgfpoint{\onethird}{-\arrowhead}} \pgflineto{\pgfpoint{\onethird}{-\arrowspread}}
\pgfclosepath % \pgfmoveto{\pgfpoint{\pgfdecoratedpathlength}{0pt}} } \state{final} {% \pgfpathlineto{\pgfpointdecoratedpathlast} } }

\tikzset{% easier to type inside of the \draw command custarr/.style={% CUSTom ARRow decorate, decoration={name=newarrow}% } }

\begin{document} \begin{tikzpicture}[line width=1mm]

% a couple of nodes to show interaction with new arrow

\node[circle,fill, inner sep=1pt, outer sep=0] (a) at (0,0) {};
\node[draw, thin, minimum size=1cm] (b) at (4,0) {};

% no modifications

\draw[custarr] (4,4) -- (b.north west); 

% a few more examples

\draw[custarr, draw=orange] (2,-2) -- (2,2); %
\draw[custarr, fill=red] (a) -- (b);
\draw[custarr, fill=green!70!black] (a) -- (2,4);

\end{tikzpicture} \end{document}

Alenanno
  • 37,338