23

I draw a line with an arrow at the end by \draw[->] .... Now I would like to make the arrow bigger, and change its color to red (without impacting the line). Does anyone know how to do it?

  • What do you mean by "bigger... without impacting the line"? Do you mean just to increase the size of the arrow-head? – Niel de Beaudrap Sep 2 '11 at 17:08
22

Here is three methods that works:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}

\draw[red,
    decoration={markings,mark=at position 1 with {\arrow[scale=4,blue]{>}}},
    postaction={decorate},
    shorten >=0.4pt
    ]
    (0,1.0) -- (2,1.0);

\draw[draw=red,-triangle 90,fill=blue]  (0,0.5) -- (2,0.5);

\draw[red]  (0,0) -- (2,0);
\draw [-to,shorten >=-1pt,gray,ultra thick] (1.99,0) -- (2,0); 

\end{tikzpicture}
\end{document}

enter image description here

I think the first method presented here is probably the way to go but perhaps more elegant solutions will be presented by other.

  • For me at position 1 did not always work. This might be a matter of low accuracy. I used at position 0.9999 as workaround. BTW: The second case, where the triangle should be filled did also not work for me; it is red. I use TikZ 3.0.1a. – John Mar 14 '17 at 17:57
  • @John: I suspect your issue is related to Arrows disappear if 0.9999 is replaced with 1 in TikZ. If you still want to get to the bottom of this I suggest posting a new question with a MWE and showing the output you get. – Peter Grill Mar 14 '17 at 20:16
14

As of PGF 3.0 (maybe another version; just going by the manual), it is a lot easier to change the style of the arrow tips compared to using post decorations. Here are similar version of the three examples given in the answer https://tex.stackexchange.com/a/27287/6993 by @Peter Grill above:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}    

  \draw[red, arrows={->[scale=4,blue]}] (0,0.0) -- (2,0.0);
  \draw[red, arrows={-Triangle[angle=90:10pt,red,fill=blue]}]  (0,1.0) -- (2,1.0);
  \draw[red, arrows={->[line width=5pt,gray,length=5mm,width=10mm]}] (0,2.0) -- (2,2.0); 

\end{tikzpicture}
\end{document}

enter image description here

10

I agree that Peter's solution is the way to go, and I think a more elegant (and reusable) solution would be to define a style using \tikzset. The below will make the style big blue arrow available in any picture in the document.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}

\begin{document}

\tikzset{
  big blue arrow/.style={
    decoration={markings,mark=at position 1 with {\arrow[scale=4,blue]{>}}},
    postaction={decorate},
    shorten >=0.4pt}}

\begin{tikzpicture}    
\draw[red, big blue arrow] (0,1.0) -- (2,1.0);

\draw[draw=red,-triangle 90,fill=blue]  (0,0.5) -- (2,0.5);

\draw[red]  (0,0) -- (2,0);
\draw [-to,shorten >=-1pt,gray,ultra thick] (1.99,0) -- (2,0); 

\end{tikzpicture}
\end{document}

It is also easy to define styles that accept an argument, and to specify a default value (I hope the code is self-explaining):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}

\begin{document}

\tikzset{
  big arrow/.style={
    decoration={markings,mark=at position 1 with {\arrow[scale=4,#1]{>}}},
    postaction={decorate},
    shorten >=0.4pt},
  big arrow/.default=blue}

\begin{tikzpicture}

\draw[red, big arrow] (0,1.0) -- (2,1.0);

\draw[red, big arrow=green]  (0,0.5) -- (2,0.5);

\end{tikzpicture}
\end{document}

output

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.