32

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?

lockstep
  • 250,273
SoftTimur
  • 19,767

3 Answers3

29

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.

Peter Grill
  • 223,288
22

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

mSSM
  • 3,152
13

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

Augusto
  • 1,149