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 am trying to get an arrow that is thick but not entirely black but has a pattern (e.g., crosshatch). I am not sure how to get this. I have the following that still gives me a black arrow:

   \documentclass[landscape]{scrartcl}      

   \usepackage{tikz}
   \usetikzlibrary{shapes,shapes.multipart,shapes.geometric,fit,positioning,arrows,matrix,decorations.pathreplacing,patterns}

   \begin{document}

   \begin{tikzpicture}
   \tikzset{
   bigbigbox/.style = {minimum width=3.5cm, rectangle},
   bigbox/.style = {draw, rectangle},
   box/.style = {minimum width=2.7cm, rounded corners,rectangle, fill=blue!20},
   square/.style = {minimum width=15mm,minimum height=15mm}
   }

   \node[square,draw,text width=1.5cm,align=center] (a1) {Map Tasks};
   \node[square,draw,right of=a1,xshift=20mm,text width=1.5cm,align=center] (a2) {Mapper Input Cache};
   \node[square,draw,below of=a1,yshift=-15mm,text width=1.5cm,align=center] (a3) {Reduce Tasks};
   \node[square,draw,below of=a2,yshift=-15mm,text width=1.5cm,align=center] (a4) {Check Fixed Point};

   \draw[-triangle 90, line width=1mm, black,pattern=crosshatch,postaction=        {draw=black,pattern=crosshatch, line width=3mm, shorten >=0.2cm, -}] (a2.west) -- (a1.east);

   \node[bigbox] [fit = (a1) (a4)] (box1){};
   \end{tikzpicture}
   \end{document}

Here is what I get:

enter image description here

share|improve this question
2  
Do something like \draw[pattern=crosshatch] (a2.west) -- (a1.east) -- (a3.east) -- cycle; to see how pattern work (it is a filling variant and does not affect the drawing). You will need to have an arrow-like area and not just one linear path. The single arrow from the shapes.arrow library may come in handy. –  Qrrbrbirlbel Feb 18 '13 at 4:53
    
I am not sure I understand the suggestion. As the code shows, I already tried the "pattern=crosshatch" without effect, which is why I am asking. Perhaps I misunderstood your suggestion. –  ozsu Feb 18 '13 at 12:50
add comment

1 Answer

up vote 8 down vote accepted

The PGF manual states regarding the Pattern Library:

The package defi nes patterns for filling areas.

The key word is filling.

You used pattern on an path that has (nearly, see below) no area. A fill would not be seen either.

My proposed solution uses the single arrow shape with a pattern:

\path let \p1=(a1.east), \p2=(a2.west), \n1={abs(\x2-\x1)} in node[
    draw,
    pattern=crosshatch,
    single arrow,
    rotate=180,
    minimum height=\n1,
    anchor=west,
    at=(a2.west),
    outer xsep=-.5\pgflinewidth,
] {};

What does happen here?

  • draw: We want an outlining border.
  • pattern=crosshatch
  • single arrow: This is a short version of shape=single arrow and declares the node’s shape.
  • rotate=180: The natural direction is 0° (right), we turn the arrow around so that it points to the left.
  • minimum height=\n1: The height (i.e. the length of the arrow) is set to the distance between the .east anchor from the left node and the .west anchor from the right node. (The calc library is used for the let … in operators.)
  • anchor=west: We use the shape’s .west anchor (the bottom of the shaft) to place the arrow.
  • at=(a2.west): The node’s .west anchor (see above) is placed at the .west anchor of the right node.
  • outer xsep=-.5\pgflinewidth: This is a cheat to overlay the shaft’s bottom line to lie exactly on the line from the right node. Comment it out to get:

    enter image description here

    In my opinion this does not look good.

Coincidentally the default dimensions of the arrow match pretty good your arrow-ed line. Check the PGF manual’s section 48.5 “Arrow Shapes” to change the appearance of the arrow further.

Nearly?

Nearly means that the arrow head itself uses drawing but the thick line width overdraws this. In the following example the opacity it set to 50 % to show that the arrow head contains a filling. The corresponding PGF command as used in the arrows library is \pgfusepathqfillstroke.

Code

\draw[line width=5mm,opacity=.5,-triangle 90,pattern=crosshatch] (0,0) -- (2,0);

Output

enter image description here

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{
    shapes.arrows,
    positioning,
    patterns,
    calc,
}
\tikzset{
    square/.style={
        minimum width=15mm,
        minimum height=15mm,
    },
}
\begin{document}
\begin{tikzpicture}
\node[square,draw,text width=1.5cm,align=center]                          (a1) {Map Tasks};
\node[square,draw,right of=a1,xshift=20mm,text width=1.5cm,align=center]  (a2) {Mapper Input Cache};
\path let \p1=(a1.east), \p2=(a2.west), \n1={abs(\x2-\x1)} in node[
    draw,
    pattern=crosshatch,
    single arrow,
    rotate=180,
    minimum height=\n1,
    anchor=west,
    at=(a2.west),
    outer xsep=-.5\pgflinewidth,
] {};
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
    
Very much appreciate this. Obviously this goes way beyond my level of expertise or comfort with tikz. I'll use this. –  ozsu Feb 18 '13 at 15:52
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.