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.

How do I fix the coloring in the arrow head? It doesn't fill like the line width does. Also, you'll notice that the arrow touches D. How do I push D down? (Or is it best to just manually adjust it?)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, positioning, trees, mindmap, calc}
\begin{document}
\begin{tikzpicture} 
\node (a) at (9,7.5) {};
\node (b) at (9,4.5) {B};
\node (c) at (10.5,6) {};
\node (d) at (7.5,6) {D};

\path[draw=black!60,solid,line width=0.8mm,fill=black!60,preaction={-triangle 90,thin,draw,shorten >=-1mm}] (a) -- (b);
\path[draw=black!60,solid,line width=0.8mm,fill=black!60,preaction={-triangle 90,thin,draw,shorten >=-1mm}] (c) -- (d);
\end{tikzpicture}
\end{document}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

If you replace the draw in the preaction option with the same style as used for the lines (fill=black!60) you get gray-ish arrows (the draw from the main action is inherited anyway).

You also shorten the arrow part (so that it will be extend further than the actual line). I’d revert this (as it is done by PGF usually when you place arrows on one path), i.e. the actual line is shortened, the arrow is not.

I also have defined a style thicker line small arrows that takes its argument in the form <line width> in <color>, which can be repeatedly used to style various lines in the same manner.

I also provide another way (the thicker line small arrows m style) that uses the markings library to place the arrow. This is not as stable as the usual preaction/postaction method, but you can place the arrow anyway on the path by the 1 in at position 1.

Code 1

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows}
\colorlet{mygray}{black!60}
\tikzset{thicker line small arrows/.style args={#1in#2}{
    draw=#2,
    solid,
    line width=#1,
    shorten >=1mm,
    preaction={
        fill=#2,
        thin,
        -triangle 90,
        shorten >=0mm,
    }
}}
\begin{document}
\begin{tikzpicture} 
\node (a) at (9,7.5) {};
\node (b) at (9,4.5) {B};
\node (c) at (10.5,6) {};
\node (d) at (7.5,6) {D};

\path[thicker line small arrows=.8mm in mygray] (a) -- (b);
\path[thicker line small arrows=.4mm in green] (c) -- (d);
\end{tikzpicture}
\end{document}

Code 2

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows, decorations.markings}
\colorlet{mygray}{black!60}
\tikzset{thicker line small arrows m/.style args={#1in#2}{
    draw=#2,
    solid,
    line width=#1,
    shorten >=1mm,
    decoration={
        markings,
        mark=at position 1.0 with {\arrow[fill=#2,thin]{triangle 90}}
    },
    postaction={decorate}
}}
\begin{document}    
\begin{tikzpicture} 
\node (a) at (9,7.5) {};
\node (b) at (9,4.5) {B};
\node (c) at (10.5,6) {};
\node (d) at (7.5,6) {D};

\path[thicker line small arrows m=.8mm in mygray] (a) -- (b);
\path[thicker line small arrows m=.4mm in green] (c) -- (d);
\end{tikzpicture}
\end{document}

Output

enter image description here

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.