[Tex/LaTex] Fancy arrows with TikZ

arrowsnodestikz-arrowstikz-pgf

I would like to draw an arrow like this using TikZ:

enter image description here

This is taken from Workflow diagram. I didn't succeed in reproducing the arrow; is somewhat beyond my (extremely limited) TikZ abilities. I don't need all the workflow stuff. I simply want to draw such an arrow at a certain place in my text, e.g. –>

\documentclass{article}
\usepackage{<???>}
\usepackage{tikz}
\usetikzlibrary{<???>}
\begin{document}
Donec vehicula augue eu neque. Pellentesque
habitant morbi \tikz <???code for the arrow???> ; tristique senectus et netus
\end{document}

PS: Some explanations in your solution would be much appreciated, otherwise it will be difficult to customize it.

Best Answer

I'm a bit late.. however this is what you need with my original code:

\documentclass[svgnames]{article}
\usepackage{tikz}
\usetikzlibrary{fadings,shapes.arrows,shadows}   

\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}}}
\tikzset{arrowstyle/.style={draw=FireBrick,arrowfill, single arrow,minimum height=#1, single arrow,
single arrow head extend=.4cm,}}

\newcommand{\tikzfancyarrow}[2][2cm]{\tikz[baseline=-0.5ex]\node [arrowstyle=#1] {#2};}

\begin{document}
This is my  \tikzfancyarrow{fancy} arrow\\
This is my  \tikzfancyarrow[3cm]{fancy} arrow\\
\end{document}

The result:

enter image description here


An improved version (requires the xparse package):

\documentclass[svgnames]{article}
\usepackage{tikz}
\usetikzlibrary{fadings,shapes.arrows,shadows}

\usepackage{xparse}

\usepackage{lipsum}

\tikzfading[name=arrowfading, top color=transparent!0, bottom color=transparent!95]
\tikzset{arrowfill/.style={#1,general shadow={fill=black, shadow yshift=-0.8ex, path fading=arrowfading}}}
\tikzset{arrowstyle/.style n args={3}{draw=#2,arrowfill={#3}, single arrow,minimum height=#1, single arrow,
single arrow head extend=.3cm,}}

\NewDocumentCommand{\tikzfancyarrow}{O{2cm} O{FireBrick} O{top color=OrangeRed!20, bottom color=Red} m}{
\tikz[baseline=-0.5ex]\node [arrowstyle={#1}{#2}{#3}] {#4};
}

\begin{document}
This is my  \tikzfancyarrow{fancy} arrow\\
This is my  \tikzfancyarrow[3cm]{fancy} arrow. \lipsum[1]

Here is another \tikzfancyarrow[2.5cm][Orchid][top color= Thistle,bottom color=Orchid]{example} of \tikzfancyarrow[3cm][SeaGreen][top color= SpringGreen,bottom color=Teal]{tikzfancyarrow} with different coloring possibility.

There is also a \tikzfancyarrow[1.5cm][DarkBlue][top color= PaleTurquoise,bottom color=DeepSkyBlue,shape border rotate=270]{rotated} arrow pointing down and a rotated\tikzfancyarrow[1.5cm][Crimson][top color= Coral,bottom color=DarkOrange,shape border rotate=90]{\phantom{cf}} arrow pointing up, upon the desire needs.
\end{document}

The result:

enter image description here

Disclaimer

With evince, I'm not able to correctly visualize the fading and the shadow; it works, at least for me, with Okular, Adobe reader and Preview (on Mac).

Explanation on the code

Taking as reference the improved example, that allows some more customization, let's have a look to the code.

At first it is defined the fading

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

giving it a name and specifying that the top color should be opaque and the bottom color almost transparent. Actually, the fading is just applied on the shadow of the arrow; indeed, when defining the style in which the arrow is filled arrowfill the fading is passed as part of the shadow:

\tikzset{arrowfill/.style={#1,general shadow={fill=black, shadow yshift=-0.8ex, path fading=arrowfading}}}

This style receives a parameter that later will be used to set the background color and the arrow direction. Actually, the style is passed to another style, arrowstyle that really defines how the arrow is:

\tikzset{arrowstyle/.style n args={3}{draw=#2,arrowfill={#3}, single arrow,minimum height=#1, single arrow,
single arrow head extend=.3cm,}}

It receives 3 parameters: the first one is the height of the arrow, the second is the color in which the border of the arrow is colored and the third is passed to arrowfill. It also declares that the shape is a single arrow and which is its single arrow head extend.

Finally, the arrow is built by means of the command:

\NewDocumentCommand{\tikzfancyarrow}{O{2cm} O{FireBrick} O{top color=OrangeRed!20, bottom color=Red} m}{
\tikz[baseline=-0.5ex]\node [arrowstyle={#1}{#2}{#3}] {#4};
}

Here the option baseline=-0.5ex says that the arrow is vertically centred in the line; the node receives 4 parameters: 3 of them are optional with default values and are passed to the style developed, while the last one is the text that eventually goes inside the arrow.

Notice that you can specify the arrow direction by means of the key shape border rotate and you don't need anything special to do so: just add it at the third optional argument.

Actually, by writing the comments I realized that one argument could be saved, that is the border color of the arrow, but I think in this way things are more clear.

Related Question