Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
You show the arrow being used in a paragraph. Is that the intent? If so, a large arrow will cause problems with interline spacing. –  Peter Grill Nov 25 '12 at 11:01
    
Yes, that's the intent! –  lpdbw Nov 25 '12 at 11:03
    
If you just paste the TeX.SE question URLs (unfortunately not the answers), the system will parse it and convert it to a proper question name. –  percusse Nov 25 '12 at 15:49
add comment

3 Answers 3

up vote 27 down vote accepted

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.

share|improve this answer
add comment

One more answer by the tikZ package with a customized arrow shape in order not to disturb the line spacing to much (as mentioned in the comments).

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{shadings,shadows,shapes.arrows}

\newcommand*{\tikzarrow}[2]{%
  \tikz[
    baseline=(A.base),             % Set baseline to the baseline of node content
    font=\footnotesize\sffamily    % Set fontsize of the node content
  ]
  \node[
    single arrow,                  % Shape of the node
    single arrow head extend=2pt,  % Actual width of arrow head
    draw,                          % Draw the node shape
    inner sep=2pt,                 % Separation between node content and node shape
    top color=white,               % Shading color on top of node
    bottom color=#1,               % Shading color on bottom of node
    drop shadow                    % Draw a shadow
  ] (A) {#2};%
}
\begin{document}
  The quick brown fox jumps over the lazy dog. \tikzarrow{red}{git add} The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
\end{document}

Further customization possible.


enter image description here


Update

As requested in the comments the below code produces an arrow that is pointing downwards. The arrow tip is modified in order to limit the disturbance of interline spacing.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{fadings,shadows,shapes.arrows}

\tikzfading[
  name=arrowfading,
  top color=transparent!0,
  bottom color=transparent!95
]
\newcommand*{\tikzarrow}[2]{%
  \tikz[
    baseline=(A.base),             % Set baseline to the baseline of node content
    font=\footnotesize\sffamily    % Set fontsize of the node content
  ]
  \node[
    single arrow,                  % Shape of the node
    single arrow head extend=4pt,  % Actual width of arrow head
    single arrow tip angle=150,    % Adjust arrow tip angle
    shape border rotate=270,       % Rotate the arrow shape to point down
    draw=red!25,                   % Draw the node shape (with certain border color
    inner sep=2pt,                 % Separation between node content and node shape
    top color=white,               % Shading color on top of node
    bottom color=#1,               % Shading color on bottom of node
    general shadow={               % Specifications for the shadow
      fill=black,
      shadow yshift=-0.5ex,
      path fading=arrowfading
    }
  ] (A) {#2};%
}
\begin{document}
  The quick brown fox jumps over the lazy dog. \tikzarrow{red}{git add} The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
\end{document}

The adjustments in particular are done by the options single arrow tip angle and shape border rotate. The problem is to find the balance between the arrow shape and the influence on interline spacing.

The border color can be specified explicitly with the draw option for the node shape. The new specifications are now done by the general shadow option. The drop shadow option is deleted. The fading of the shadow is determined by the \tikzfading command, which generates the arrowfading style.


enter image description here


Further reading

share|improve this answer
    
How would I have to change the code to get an arrow pointing downwards? It should also be placed in the current line and is intended to serve as a symbol for "see below". One somehow has to take even more care that line spacing does not get tretched too much ... –  lpdbw Nov 25 '12 at 14:02
1  
@lpdbw: I have added an example with regard to your remarks. –  Thorsten Donig Nov 25 '12 at 15:20
    
I tried but failed to incorporate the following feautures of @Claudio Fiandrino's red arrow (see answer below) into the solution of this answer: 1) fading of the shadow. 2) Boundary of the arrow red instead of black. Is that possible? –  lpdbw Nov 26 '12 at 8:03
    
@lpdbw: I have modified the (second) example accordingly. –  Thorsten Donig Nov 26 '12 at 16:42
add comment

Below I have defined a macro \Arrow (based on Workflow diagram) that can be used for this:

enter image description here

The default parameters are specified in the My Arrow Style, but you can use the optional first parameter to adjust as desired. Most of the options that are used below should be almost self-explanatory:

  • fill= specifies the fill color

  • align= is used to control the alignment of the text (try using left, right to see the effect.

  • text width= is the width of the text field

  • draw= specifies the line color drawn around the edge of the arrow

  • ultra thick = is used to control the line width.

You should refer to the TikX/PGF manual for more details. If there is a specific option you are trying to customize I can elaborate further,

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}

\tikzset{My Arrow Style/.style={single arrow, fill=red!50, anchor=base, align=center,text width=2.8cm}}
\newcommand{\MyArrow}[2][]{\tikz[baseline] \node [My Arrow Style,#1] {#2};}

\begin{document}
Some text before \MyArrow{some text} and some text after

\bigskip
Some text before \MyArrow[fill=yellow!50, draw=black, ultra thick, text width=3.5cm]{some text} and some text after
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.