11

Is it possible to draw arrows (preferential with TikZ) with two images: One for the line and one for the tip?

I would like to realize something like this:

enter image description here

  • Do you want to use it more than once? I mean is it going to be frequent line style for drawing arrows from a to b or you just want to create this shape once? – percusse Jun 13 '12 at 13:45
  • I would like to use it more than once. The company is redesigning the template for presentations and I'm trying to build a tex style to have the ability to make these new fancy presentations - still with tex. – Bertram Nudelbach Jun 13 '12 at 13:48
  • Using the shapes.geometric library of tikz, you can have something like : \begin{tikzpicture}[every node/.style={draw,fill=blue!10,minimum height=1cm,minimum width=4mm}] \foreach \x in {1,...,5} { \node (l\x) at (0.6*\x,0) {};} \filldraw[fill=blue!10] ([xshift=2mm] l5.south east) -- ([xshift=2mm] l5.north east) -- ++(5mm,-0.5cm) -- cycle; \end{tikzpicture} but is this portable enough or there must be a genuine line style? – percusse Jun 13 '12 at 14:08
  • 1
    This is related: Best way to draw a chevron diagram using Tikz – Count Zero Jun 13 '12 at 14:15
  • @percusse yes that's a good starting point. But it would be nice to at least be able to define start and end - and the line should know how many rectangles to draw .. – Bertram Nudelbach Jun 13 '12 at 14:21
13

Here is a different approach from what @percusse suggested. I used decorations to get the rectangles along the line:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}

\usepackage{tikz}

\usetikzlibrary{shapes, decorations.shapes, }

\begin{document}
    \begin{tikzpicture}[decoration={shape backgrounds,shape=rectangle,shape width=4mm, shape height=10mm},
            paint/.style={decorate, draw=#1!50!black, fill=#1!50}]]
        \node (A) at (0,0) {};
        \node [isosceles triangle, isosceles triangle apex angle=120, draw=blue!50!black, fill= blue!50, inner sep=1.1mm] (B) at (3.05,0) {};
        \path [draw, paint=blue, decoration={shape sep=0.5cm}] (A)-- (B);
    \end{tikzpicture}
\end{document}

It can be tweaked to wrap it into a single macro that takes for argument e.g. the length.

enter image description here

EDIT: Here is another version that is rotationally correct:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}

\usepackage{tikz}

\usetikzlibrary{positioning, shapes, decorations.shapes, decorations.markings}

\begin{document}
    \begin{tikzpicture}[%
    paint/.style={draw=#1!50!black, fill=#1!50},
    linedeco/.style={decoration={%
        markings,
        mark=between positions 0 and 1 step #1 with {\draw (-1mm,-5mm) rectangle (1mm,5mm) [paint=blue];},
        mark=at position 1 with
            {\node [paint=blue, isosceles triangle, isosceles triangle apex angle=120, inner sep=1.1mm, transform shape] {};
            },
        }}]
        \node (A) at (0,0) {};
        \node (B) at (3,5) {};
        \path [paint=blue, decorate, linedeco=0.05] (A)--(B);
        \node (C) at (0,-2) {};
        \node (D) at (3,-2) {};
        \path [paint=blue, decorate, linedeco=0.1] (C)--(D);
    \end{tikzpicture}
\end{document}

It takes a parameter you need to set manually, depending on the angles.

enter image description here

  • Nice one. You can also add a triangle node in the end with the markings decoration and then it would be complete :) Bah, vote cap... – percusse Jun 13 '12 at 14:22
  • I like this one! Is it possible to improve it to be able to draw from e.g. (0,0) to (5,3)? Currently the triangle isn't drawn correctly. – Bertram Nudelbach Jun 13 '12 at 14:25
  • 1
    Looks great now! – percusse Jun 13 '12 at 17:17
  • @percusse: Thanks! :) It would be really nice if I could automate the spacing, based on the actual orientation. I'll have to figure that out later... – Count Zero Jun 13 '12 at 19:02

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.