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'm trying to draw an arrow with a bigger head than normal. Is it possible without changing the style of the line itself?

share|improve this question
    
Have you checked out section 58 of the TikZ manual? –  Harald Hanche-Olsen Nov 16 '10 at 13:02
    
@Harald Yes, just checked. Looks perfect, but it's an overkill for my simple task. Maybe you can suggest an easier way? –  yegor256 Nov 16 '10 at 13:48
    
Not me (not a TikZ user yet), but if there is an easier way, someone will come up with it. –  Harald Hanche-Olsen Nov 16 '10 at 14:16
    
@HaraldHanche-Olsen LOL you said "58" without a trace of sarcasm. That manual is bigger than most Mercedes User Manuals =P –  puk Feb 9 '12 at 9:28
1  
@puk: Yes indeed, but it does have a table of contents, you know. As well as an index. When I recheck now, however, section 58 doesn't look right anymore (in the 2.1 manual). I guess stuff has been moved about in there. Sorry, I don't have the time right now to find it again. Next time, I should provide the section title as well. –  Harald Hanche-Olsen Feb 9 '12 at 13:00

8 Answers 8

up vote 104 down vote accepted
+1000

Update 2013-02-27

This code is now superseded by the new arrows.meta library bundled with TikZ 3.0.0.


Update 2013-01-23

The development version of the complete code is now available on sourceforge. The old arrowhead key is now replaced by arrow head to give consistency with the other keywords in the package.


Update 2012-11-13

I edited all the predefined arrow tips and those in the arrows library, except for the "almost 0d" ones (serif cm, space and all the line caps arrows) and implies (because I think it depends indeed on the line width), whose original code has been included for completeness, so that one can find all the previously available arrows in just a single code.

For "almost 1d" arrow tips (hooks like, and bracket like), the arrowhead value sets the height of the tip, instead of its length (for left and right variants, the height of the whole hook).

The code of the to new arrow has now been fixed. For 45 degrees arrows, the amplitude of the tip is actually 45° and not 46° as in the original code.

Of course, you can use the new arrows as markings too.

I can't upload the new code because it exceeds the size limit for the answers, but I'm posting a picture of the result of the new test file. I sent an email to Till Tantau asking to turn the code in a new TikZ library and we'll see.


I'm not a TikZ guru, so I've done what I could. Therefore everyone is invited to improve the code, and I really think it can be improved. Save the new arrows code as arrowsnew.tex and load it by means of \input{arrowsnew} in your preamble. There are nine new arrows named latexnew, latexnew reversed, latex'new, latex'new reversed, onew, squarenew, stealthnew, stealthnew reversed and tonew (or >new). It works like this: if you call an arrow without the arrowhead key or you don't assign it any value, the original code is used, so that the new code can fully replace the old one. Otherwise, if you assign a value to the arrowhead key, the lenght of the arrowhead will be set to <value>. At the moment, the tonew arrow is slightly different from the original. Please, don't directly edit the code, but feel free to reuse/edit it in a new answer.

The result of the new code 2012-11-13

enter image description here

The old test code

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\input{arrowsnew}

\tikzset{options/.code={\tikzset{#1}}} % just to compact the code

\begin{document}
\begin{tikzpicture}
\draw [red] (2,-24.2) -- (2,0.2) node [above right, black] {1 cm};
\draw [red] (3,-24.2) -- (3,0.2);
\foreach \x [count=\i from 0] in {
  {latex-latexnew},
  {latex-latexnew, arrowhead=1cm},
  {latex-latexnew, arrowhead=1cm, line width=1pt},
  {latex reversed-latexnew reversed, arrowhead=1cm, line width=1pt},
  {latex'-latex'new},
  {latex'-latex'new, arrowhead=1cm},
  {latex'-latex'new, arrowhead=1cm, line width=2pt},
  {latex' reversed-latex'new reversed, arrowhead=1cm, line width=2pt},
  {o-onew},
  {o-onew, arrowhead=1cm},
  {o-onew, arrowhead=1cm, line width=2pt},
  {square-squarenew},
  {square-squarenew, arrowhead=1cm},
  {square-squarenew, arrowhead=1cm, ultra thick},
  {stealth-stealthnew},
  {stealth-stealthnew, arrowhead=1cm},
  {stealth-stealthnew, arrowhead=1cm, ultra thick},
  {stealth reversed-stealthnew reversed, arrowhead=1cm, ultra thick},
  {to-tonew},
  {to-tonew, arrowhead=1cm}
}
{
  \draw [options/.expand once=\x] (0,-1.2*\i) -- (3,-1.2*\i) node [right] {\x};
}
\draw [<->new, arrowhead=0.25in, line width=4pt] (0,-24) -- (3,-24)
      node [right] {\verb!<->!new, arrowhead=0.25in, line width=4pt};  
\draw [red] (3,-23.2) ++ (-0.25in,0) -- ++(0,-1.6) node [below,black] {0.25 in}; 
\end{tikzpicture}
\end{document}

The result

enter image description here

The old arrowsnew code (superseded)

% This is not an official TikZ library. Use at your own risk!

\makeatletter
% alternative latex arrow
\pgfarrowsdeclare{latexnew}{latexnew}
{
  \ifdim\pgfgetarrowoptions{latexnew}=-1pt%
    \pgfutil@tempdima=0.28pt%
    \pgfutil@tempdimb=\pgflinewidth%
    \ifdim\pgfinnerlinewidth>0pt%
      \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
    \fi%
    \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \else%
    \pgfutil@tempdima=\pgfgetarrowoptions{latexnew}%
    \divide\pgfutil@tempdima by 10%
  \fi%
  \pgfarrowsleftextend{+-1\pgfutil@tempdima}%
  \pgfarrowsrightextend{+9\pgfutil@tempdima}%
}
{
  \ifdim\pgfgetarrowoptions{latexnew}=-1pt%
    \pgfutil@tempdima=0.28pt%
    \pgfutil@tempdimb=\pgflinewidth%
    \ifdim\pgfinnerlinewidth>0pt%
      \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
    \fi%
    \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \else%
    \pgfutil@tempdima=\pgfgetarrowoptions{latexnew}%
    \divide\pgfutil@tempdima by 10%
    \pgfsetlinewidth{0bp}%
  \fi%
  \pgfpathmoveto{\pgfqpoint{9\pgfutil@tempdima}{0pt}}
  \pgfpathcurveto
  {\pgfqpoint{6.3333\pgfutil@tempdima}{.5\pgfutil@tempdima}}
  {\pgfqpoint{2\pgfutil@tempdima}{2\pgfutil@tempdima}}
  {\pgfqpoint{-1\pgfutil@tempdima}{3.75\pgfutil@tempdima}}
  \pgfpathlineto{\pgfqpoint{-1\pgfutil@tempdima}{-3.75\pgfutil@tempdima}}
  \pgfpathcurveto
  {\pgfqpoint{2\pgfutil@tempdima}{-2\pgfutil@tempdima}}
  {\pgfqpoint{6.3333\pgfutil@tempdima}{-.5\pgfutil@tempdima}}
  {\pgfqpoint{9\pgfutil@tempdima}{0pt}}
  \pgfusepathqfill
}

% alternative latex reversed arrow
\pgfarrowsdeclarereversed{latexnew reversed}{latexnew reversed}{latexnew}{latexnew}

% alternative latex' arrow
\pgfarrowsdeclare{latex'new}{latex'new}
{
  \ifdim\pgfgetarrowoptions{latex'new}=-1pt%
    \pgfutil@tempdima=0.28pt%
    \advance\pgfutil@tempdima by.3\pgflinewidth%
  \else%
    \pgfutil@tempdima=\pgfgetarrowoptions{latex'new}%
    \divide\pgfutil@tempdima by 10%
  \fi%
  \pgfarrowsleftextend{+-4\pgfutil@tempdima}
  \pgfarrowsrightextend{+6\pgfutil@tempdima}
}
{
  \ifdim\pgfgetarrowoptions{latex'new}=-1pt%
    \pgfutil@tempdima=0.28pt%
    \advance\pgfutil@tempdima by.3\pgflinewidth%
  \else%
    \pgfutil@tempdima=\pgfgetarrowoptions{latex'new}%
    \divide\pgfutil@tempdima by 10%
    \pgfsetlinewidth{0bp}%
  \fi%
  \pgfpathmoveto{\pgfqpoint{6\pgfutil@tempdima}{0\pgfutil@tempdima}}
  \pgfpathcurveto
  {\pgfqpoint{3.5\pgfutil@tempdima}{.5\pgfutil@tempdima}}
  {\pgfqpoint{-1\pgfutil@tempdima}{1.5\pgfutil@tempdima}}
  {\pgfqpoint{-4\pgfutil@tempdima}{3.75\pgfutil@tempdima}}
  \pgfpathcurveto
  {\pgfqpoint{-1.5\pgfutil@tempdima}{1\pgfutil@tempdima}}
  {\pgfqpoint{-1.5\pgfutil@tempdima}{-1\pgfutil@tempdima}}
  {\pgfqpoint{-4\pgfutil@tempdima}{-3.75\pgfutil@tempdima}}
  \pgfpathcurveto
  {\pgfqpoint{-1\pgfutil@tempdima}{-1.5\pgfutil@tempdima}}
  {\pgfqpoint{3.5\pgfutil@tempdima}{-.5\pgfutil@tempdima}}
  {\pgfqpoint{6\pgfutil@tempdima}{0\pgfutil@tempdima}}
  \pgfusepathqfill
}

% alternative latex' reversed arrow
\pgfarrowsdeclarereversed{latex'new reversed}{latex'new reversed}{latex'new}{latex'new}

% alternative o arrow
\pgfarrowsdeclare{onew}{onew}
{
  \pgfarrowsleftextend{+-.5\pgflinewidth}
  \ifdim\pgfgetarrowoptions{onew}=-1pt%
    \pgfutil@tempdima=0.4pt%
    \advance\pgfutil@tempdima by.2\pgflinewidth%
    \pgfutil@tempdimb=9\pgfutil@tempdima\advance\pgfutil@tempdimb by.5\pgflinewidth%
    \pgfarrowsrightextend{+\pgfutil@tempdimb}%
  \else%
    \pgfutil@tempdima=\pgfgetarrowoptions{onew}%
    \advance\pgfutil@tempdima by -0.5\pgflinewidth%
    \pgfarrowsrightextend{+\pgfutil@tempdima}%
  \fi%
}
{ 
  \ifdim\pgfgetarrowoptions{onew}=-1pt%
    \pgfutil@tempdima=0.4pt%
    \advance\pgfutil@tempdima by.2\pgflinewidth%
    \pgfutil@tempdimb=0pt%
  \else%
    \pgfutil@tempdima=\pgfgetarrowoptions{onew}%
    \divide\pgfutil@tempdima by 9%
    \pgfutil@tempdimb=0.5\pgflinewidth%
  \fi%
  \pgfsetdash{}{+0pt}
  \pgfpathcircle{\pgfpointadd{\pgfqpoint{4.5\pgfutil@tempdima}{0bp}}%
                             {\pgfqpoint{-\pgfutil@tempdimb}{0bp}}}%
                {4.5\pgfutil@tempdima-\pgfutil@tempdimb}%
  \pgfusepathqstroke
}

% alternative square arrow
\pgfarrowsdeclare{squarenew}{squarenew}
{
 \ifdim\pgfgetarrowoptions{squarenew}=-1pt%
   \pgfutil@tempdima=0.4pt
   \advance\pgfutil@tempdima by.275\pgflinewidth%
   \pgfarrowsleftextend{+-\pgfutil@tempdima}
   \advance\pgfutil@tempdima by.5\pgflinewidth
   \pgfarrowsrightextend{+\pgfutil@tempdima}
 \else%
   \pgfutil@tempdima=\pgfgetarrowoptions{squarenew}%
   \divide\pgfutil@tempdima by 8%
   \pgfarrowsleftextend{+-7\pgfutil@tempdima}%
   \pgfarrowsrightextend{+1\pgfutil@tempdima}%
 \fi%
}
{
 \ifdim\pgfgetarrowoptions{squarenew}=-1pt%
   \pgfutil@tempdima=0.4pt%
   \advance\pgfutil@tempdima by.275\pgflinewidth%
   \pgfutil@tempdimb=0pt%
 \else%
   \pgfutil@tempdima=\pgfgetarrowoptions{squarenew}%   
   \divide\pgfutil@tempdima by 8%
   \pgfutil@tempdimb=0.5\pgflinewidth%
 \fi%
 \pgfsetdash{}{+0pt}
 \pgfsetroundjoin
 \pgfpathmoveto{\pgfpointadd{\pgfqpoint{1\pgfutil@tempdima}{4\pgfutil@tempdima}}
                            {\pgfqpoint{-\pgfutil@tempdimb}{-\pgfutil@tempdimb}}}
 \pgfpathlineto{\pgfpointadd{\pgfqpoint{-7\pgfutil@tempdima}{4\pgfutil@tempdima}}
                            {\pgfqpoint{\pgfutil@tempdimb}{-\pgfutil@tempdimb}}}
 \pgfpathlineto{\pgfpointadd{\pgfqpoint{-7\pgfutil@tempdima}{-4\pgfutil@tempdima}}
                            {\pgfqpoint{\pgfutil@tempdimb}{\pgfutil@tempdimb}}}
 \pgfpathlineto{\pgfpointadd{\pgfqpoint{1\pgfutil@tempdima}{-4\pgfutil@tempdima}}
                            {\pgfqpoint{-\pgfutil@tempdimb}{\pgfutil@tempdimb}}}
 \pgfpathclose
 \pgfusepathqfillstroke
}

% alternative stealth arrow
\pgfarrowsdeclare{stealthnew}{stealthnew}
{
  \ifdim\pgfgetarrowoptions{stealthnew}=-1pt%
    \pgfutil@tempdima=0.28pt%
    \pgfutil@tempdimb=\pgflinewidth%
    \ifdim\pgfinnerlinewidth>0pt%
      \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
    \fi%
    \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \else%
    \pgfutil@tempdima=\pgfgetarrowoptions{stealthnew}%
    \divide\pgfutil@tempdima by 8%
  \fi%
  \pgfarrowsleftextend{+-3\pgfutil@tempdima}
  \pgfarrowsrightextend{+5\pgfutil@tempdima}
}
{
  \ifdim\pgfgetarrowoptions{stealthnew}=-1pt%
    \pgfutil@tempdima=0.28pt%
    \pgfutil@tempdimb=\pgflinewidth%
    \ifdim\pgfinnerlinewidth>0pt%
      \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
    \fi%
    \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \else%
    \pgfutil@tempdima=\pgfgetarrowoptions{stealthnew}%
    \divide\pgfutil@tempdima by 8%
    \pgfsetlinewidth{0bp}%
  \fi%
  \pgfpathmoveto{\pgfqpoint{5\pgfutil@tempdima}{0pt}}
  \pgfpathlineto{\pgfqpoint{-3\pgfutil@tempdima}{4\pgfutil@tempdima}}
  \pgfpathlineto{\pgfpointorigin}
  \pgfpathlineto{\pgfqpoint{-3\pgfutil@tempdima}{-4\pgfutil@tempdima}}
  \pgfusepathqfill
}

% alternative stealth reversed arrow
\pgfarrowsdeclarereversed{stealthnew reversed}{stealthnew reversed}{stealthnew}{stealthnew}

% alternative to arrow
\pgfarrowsdeclare{tonew}{tonew}
{
  \ifdim\pgfgetarrowoptions{tonew}=-1pt%
    \pgfutil@tempdima=0.84pt%
    \advance\pgfutil@tempdima by1.3\pgflinewidth%
    \pgfutil@tempdimb=0.21pt%
    \advance\pgfutil@tempdimb by.625\pgflinewidth%
  \else%
    \pgfutil@tempdima=\pgfgetarrowoptions{tonew}%
    \pgfarrowsleftextend{+-0.8\pgfutil@tempdima}%
    \pgfarrowsrightextend{+0.2\pgfutil@tempdima}%
  \fi%
}
{
  \ifdim\pgfgetarrowoptions{tonew}=-1pt%
    \pgfutil@tempdima=0.28pt%
    \advance\pgfutil@tempdima by.3\pgflinewidth%
    \pgfutil@tempdimb=0pt,%
  \else%
    \pgfutil@tempdima=\pgfgetarrowoptions{tonew}%
    \multiply\pgfutil@tempdima by 100%
    \divide\pgfutil@tempdima by 375%
    \pgfutil@tempdimb=0.4\pgflinewidth%
  \fi%
  \pgfsetdash{}{+0pt}
  \pgfsetroundcap
  \pgfsetroundjoin
  \pgfpathmoveto{\pgfpointorigin}
  \pgflineto{\pgfpointadd{\pgfpoint{0.75\pgfutil@tempdima}{0bp}}
                         {\pgfqpoint{-2\pgfutil@tempdimb}{0bp}}}
  \pgfusepathqstroke
  \pgfsetlinewidth{0.8\pgflinewidth}
  \pgfpathmoveto{\pgfpointadd{\pgfqpoint{-3\pgfutil@tempdima}{4\pgfutil@tempdima}}
                             {\pgfqpoint{\pgfutil@tempdimb}{0bp}}}
  \pgfpathcurveto
  {\pgfpointadd{\pgfqpoint{-2.75\pgfutil@tempdima}{2.5\pgfutil@tempdima}}
               {\pgfqpoint{0.5\pgfutil@tempdimb}{0bp}}}
  {\pgfpointadd{\pgfqpoint{0pt}{0.25\pgfutil@tempdima}}
               {\pgfqpoint{-0.5\pgfutil@tempdimb}{0bp}}}
  {\pgfpointadd{\pgfqpoint{0.75\pgfutil@tempdima}{0pt}}
               {\pgfqpoint{-\pgfutil@tempdimb}{0bp}}}
  \pgfpathcurveto
  {\pgfpointadd{\pgfqpoint{0pt}{-0.25\pgfutil@tempdima}}
               {\pgfqpoint{-0.5\pgfutil@tempdimb}{0bp}}}
  {\pgfpointadd{\pgfqpoint{-2.75\pgfutil@tempdima}{-2.5\pgfutil@tempdima}}
               {\pgfqpoint{0.5\pgfutil@tempdimb}{0bp}}}
  {\pgfpointadd{\pgfqpoint{-3\pgfutil@tempdima}{-4\pgfutil@tempdima}}
               {\pgfqpoint{\pgfutil@tempdimb}{0bp}}}
  \pgfusepathqstroke
}

% alias alternative to arrow
\pgfarrowsdeclarealias{<new}{>new}{tonew}{tonew}

\makeatother

% tip length code
\pgfsetarrowoptions{latexnew}{-1pt}
\pgfsetarrowoptions{latex'new}{-1pt}
\pgfsetarrowoptions{onew}{-1pt}
\pgfsetarrowoptions{squarenew}{-1pt}
\pgfsetarrowoptions{stealthnew}{-1pt}
\pgfsetarrowoptions{tonew}{-1pt}
\pgfkeys{/tikz/.cd, arrowhead/.default=-1pt, arrowhead/.code={
  \pgfsetarrowoptions{latexnew}{#1},
  \pgfsetarrowoptions{latex'new}{#1},
  \pgfsetarrowoptions{onew}{#1},
  \pgfsetarrowoptions{squarenew}{#1},
  \pgfsetarrowoptions{stealthnew}{#1},
  \pgfsetarrowoptions{tonew}{#1},
}}
share|improve this answer
12  
Excellent answer. Maybe you could submit it as a patch to tikz? Should be quite useful! BTW, also illustrates why one normally shouldn't touch the default arrowhead sizes... (-; –  gerrit Nov 4 '12 at 22:16
1  
@gerrit, thank you. I'm going to add more arrowheads, then we'll see. As I told to Andrew Stacey, I don't feel up to design a new package, but I'm contacting Till Tantau and seeing if he is interested in fine tuning my code. –  Luigi Nov 5 '12 at 17:38
3  
By the way great work! –  percusse Nov 11 '12 at 20:11
2  
This feature request has been changed to “open-accepted” by Till Tantau: “ I have been thinking about how to integrate this. It seems like a good idea that a general "arrow tip size" should be an always present arrow option, which would simplify most of the code. When I have the time, I will address arrow tips in general and then integrate this.” –  Qrrbrbirlbel Aug 31 '13 at 2:48
    
I had to remove all the commas in the last code block of arrowsnew.tex, because it was causing the error "Missing character: There is no , in font nullfont!" –  Dan Stahlke Jul 4 at 15:54

Here is a sample of the outward-pointing triangular tips in PGF/TikZ 2.10 (see Section 23 of the 2.10 manual):

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\newcounter{tmp}
\begin{tikzpicture}
\foreach \s in {latex,latex',stealth,triangle 90,triangle 45,angle 90, angle 60} {
    \stepcounter{tmp}
    \begin{scope}[yshift=-\thetmp cm]
        \node[anchor=west] (0,0) {\texttt{\s}};     
        \draw[arrows={\s-\s}] (3,0) --++ (1,0);
    \end{scope}
}
\end{tikzpicture}
\end{document}

arrows

If you want something more customized or more specific, read Section 74 of the 2.10 manual. How much bigger and in what direction are you looking for?

share|improve this answer
    
Great answer. I found this very helpful. –  bobobobo Aug 8 '12 at 17:24
6  
How does this answers my question? –  yegor256 Dec 19 '12 at 18:38

Arrow sizes change with the line width. For example for thin and ultra thick lines:

thin and ultra thick arrow

If you do not want to have the whole line thicker, you can use the decoration library to add an enlarged arrow to your path. Here are two possibilities:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}

\begin{tikzpicture}
   \draw[->] (0,0) -- (1,0);
   \draw[
    decoration={markings,mark=at position 1 with {\arrow[ultra thick]{>}}},
    postaction={decorate}
    ]
    (0,-0.5) -- (1,-0.5);
   \draw[
    decoration={markings,mark=at position 1 with {\arrow[scale=2]{>}}},
    postaction={decorate},
    shorten >=0.4pt
    ]
    (0,-1) -- (1,-1);
\end{tikzpicture}

\end{document}

bigger arrows as decorations

Decorations are explained in chapter 30 of the TikZ 2.10 manual. The shorten >=0.4pt in the last example shortens the line by the default line width (0.4pt) so that it does not extend over the arrow tip (though the effect is nearly invisible for normal thin lines.

share|improve this answer
2  
decorations is definitely better than coding your own arrow. Good answer. –  Matthew Leingang Nov 16 '10 at 19:23
    
Yes Decoration is lots better but how would i change the line thickness –  Aku Jan 21 '11 at 1:55

i just stumbled on the same problem, but those solutions didn’t fit my need. but i remembered postactions, so i came up with this:

\usetikzlibrary{arrows}
\begin{tikzpicture}
    \draw[
        -triangle 90,
        line width=4mm,
        postaction={draw, line width=1cm, shorten >=1cm, -}
    ] (0,0) -- (2,0);
\end{tikzpicture}

http://i.stack.imgur.com/WbXRg.png

The idea is to choose a line width which yields the right arrow head, and then draw the line again with a fatter line.

Of course it only works when you need the line to be fatter than the head.

share|improve this answer
    
This is a cool arrow too - thanks :) –  sdaau Jan 30 '11 at 23:36
1  
No problem. I used it to mimick minecraft’s crafting screen arrow :) –  flying sheep Apr 26 '11 at 9:23

Here's an alternative approach that replaces the arrow-rendering code with a customised version which allows for an extra scale factor to be applied (with only a little more work it would be possible to make it so that you could specify some formula to apply rather than just a linear scale factor and also provide different adjustments for the start and end). It does this by changing the line width just before the arrow is drawn and then restoring it afterwards. (It was derived from some code I had whose aim was to draw an arrow on a doubled line which used the inner line width instead of the outer one. I thought that was from a question here but can't find it now.)

This has the obvious advantage of not needing to modify every single arrow definition!

There are two macros to modify: the one that draws the arrows and the one that shortens the line.

\documentclass{article}
\usepackage{tikz}
%\url{http://tex.stackexchange.com/q/5461/86}

\makeatletter
\pgfkeys{
  /pgf/scalable arrows/.code={
    \let\pgf@add@arrows@as@needed=\pgf@add@scalable@arrows@as@needed
    \let\pgf@shorten@path@as@needed=\pgf@shorten@path@as@needed@for@scalable
  },
  /pgf/arrow scale factor/.initial=1,
}

\def\pgf@add@scalable@arrows@as@needed{%
  \pgfkeysgetvalue{/pgf/arrow scale factor}{\pgf@temp}%
  \let\pgf@restorelw=\pgfutil@empty
  \ifx\pgf@temp\pgfutil@empty
  \else
  \edef\pgf@restorelw{\noexpand\pgfsetlinewidth{\the\pgflinewidth}}%
  \pgfsetlinewidth{\pgf@temp\pgflinewidth}%
  \fi
  \ifx\pgf@startarrow\pgfutil@empty%
  \else%
    \pgflowlevelobj%
      {\pgftransformarrow{\pgfpointsecondonpath}{\pgfpointfirstonpath}}
      {\pgf@startarrow}%
  \fi%
  \ifx\pgf@endarrow\pgfutil@empty%
  \else%
    \pgflowlevelobj%
      {\pgftransformarrow{\pgfpointsecondlastonpath}{\pgfpointlastonpath}}
      {\pgf@endarrow}%
  \fi%
      \pgf@restorelw%
}

\def\pgf@shorten@path@as@needed@for@scalable{%
  \pgfkeysgetvalue{/pgf/arrow scale factor}{\pgf@temp}%
  \let\pgf@restorelw=\pgfutil@empty
  \ifx\pgf@temp\pgfutil@empty
  \else
  \edef\pgf@restorelw{\noexpand\pgfsetlinewidth{\the\pgflinewidth}}%
  \pgfsetlinewidth{\pgf@temp\pgflinewidth}%
  \fi
  \pgfprocesspathextractpoints{\pgf@arrowpath}%
  \let\pgf@arrow@next=\pgf@shorten@now%
  \ifx\pgf@shorten@start\pgfutil@empty%
    \ifx\pgf@shorten@end\pgfutil@empty%
      \ifdim\pgf@shorten@end@additional=0pt\relax%
        \ifdim\pgf@shorten@start@additional=0pt\relax%
          \let\pgf@arrow@next=\relax%
        \fi%
      \fi%
    \fi%
  \fi%
  \pgf@arrow@next%
  \pgf@restorelw%
}

\makeatother

\begin{document}
\begin{tikzpicture}
\begin{scope}[xshift=3cm]
\draw[green] (2,1) -- (2,-3);
\draw[line width=4pt,->] (0,0) -- (2,0);
\draw[line width=4pt,->] (0,-1) -- (2,-1);
\draw[line width=2pt,->] (0,-2) -- (2,-2);
\end{scope}
\begin{scope}[xshift=6cm]
\draw[green] (2,1) -- (2,-3);
\draw[line width=8pt,->] (0,0) -- (2,0);
\draw[line width=2pt,->] (0,-1) -- (2,-1);
\draw[line width=2pt,->] (0,-2) -- (2,-2);
\end{scope}
\begin{scope}[scalable arrows]
\draw[green] (2,1) -- (2,-3);
\draw[arrow scale factor=2,line width=4pt,->] (0,0) -- (2,0);
\draw[arrow scale factor=.5,line width=4pt,->] (0,-1) -- (2,-1);
\draw[line width=2pt,->] (0,-2) -- (2,-2);
\end{scope}
\end{tikzpicture}
\end{document}

Scalable arrows

The first column has the scalable arrows. The second shows what they would look like with no scaling, the third shows what they would look like with the line width to get that size arrow naturally. The green line is to show that the shortening is correctly applied.

share|improve this answer
    
Ah, lazy! =) That's a very clever approach! –  Jake Oct 30 '12 at 12:06
    
@Jake Doubly so since I had the code lying around anyway (almost). –  Loop Space Oct 30 '12 at 12:11
    
@Jake !! I didn't answer this for the bounty. The bounty reminded me that it was an open problem and one that there was considerable interest in seeing a solution. If you do something like that again I'll have to stop answering bountied questions. –  Loop Space Nov 4 '12 at 20:07
    
@Jake, you are very generous. I think both Andrew and I didn't reply just for the bounty, but because the challenge was very interesting. So if you didn't assign it yesterday, it would have been the same to me. Thanks. –  Luigi Nov 4 '12 at 20:15
    
@Jake, as you can see, Andrew and I are on the same wavelength: I started writing before reading Andrew's comment. –  Luigi Nov 4 '12 at 20:18

I feel your pain there. The regular arrow head is almost invisible. You can declare your own arrow head using \pgfarrowsdeclare. You can modify the example below using commands from chapters 71 and 74 of the pgf manual. This is a simpler version of the example from chapter 74, which I latexified a bit while I was at it. Hope that helps. The idea behind declaring your own length is that it's going to scale with line thickness when you do it this way.

\newlength{\arrowsize}  
\pgfarrowsdeclare{biggertip}{biggertip}{  
  \setlength{\arrowsize}{0.4pt}  
  \addtolength{\arrowsize}{.5\pgflinewidth}  
  \pgfarrowsrightextend{0}  
  \pgfarrowsleftextend{-5\arrowsize}  
}{  
  \setlength{\arrowsize}{0.4pt}  
  \addtolength{\arrowsize}{.5\pgflinewidth}  
  \pgfpathmoveto{\pgfpoint{-5\arrowsize}{4\arrowsize}}  
  \pgfpathlineto{\pgfpointorigin}  
  \pgfpathlineto{\pgfpoint{-5\arrowsize}{-4\arrowsize}}  
  \pgfusepathqstroke  
}  

To use your arrow afterwards, say something like

\draw[-biggertip] (0,0) -- (0,1);
share|improve this answer

TikZ v3.0 (among other new features) includes a new arrows.meta library. It's probably inspired in Luigi's library and deprecates previous arrows and arrows.spaced libraries.

With this new library, it's very easy to define arrowhead parameters like length or width depending or not from line width.

\draw[-{Latex[length=3mm,width=5mm]}] (0,0)--(2,0);

will draw an arrow with a Latex arrowhead 3mm long and 5mm thick. All new arrows have changed their name which now starts with a capital letter to distinguish them from old names. Of course old names are still valid but they don't accept options as in previous example.

It's worth to read section "16 Arrows" in pgfmanual.

Some little examples:

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw[-latex] (0,0)--(2,0) node[right]{\emph{Old} latex arrow};
\draw[-Latex] (0,-.5)--(2,-.5) node[right]{\emph{new} Latex arrow};
\draw[-{Latex[length=3mm]}] (0,-1)--(2,-1) node[right]{with fixed length};
\draw[-{Latex[width=3mm]}] (0,-1.5)--(2,-1.5) node[right]{with fixed width};
\draw[-{Latex[length=5mm, width=2mm]}] (0,-2)--(2,-2) node[right]{widh fixed length and width};
\draw[-{Latex[red]}] (0,-2.5)--(2,-2.5) node[right]{with colorful tip};
\end{tikzpicture}
\end{document}

enter image description here

More examples about using arrows.meta:

share|improve this answer

Here is a simple example of how to change all arrow heads in a document. On modern tikz versions, the arrows.meta tikz library provides a variety of customisable arrow heads and \tikzset can be used to set the default arrow style:

\documentclass{standalone}

\usepackage{tikz}

% add the following two lines to your document to get bigger arrows
\usetikzlibrary{arrows.meta}
\tikzset{>={Latex[width=3mm,length=3mm]}}

\begin{document}

\begin{tikzpicture}
\draw[->] (0,0) node[left]{from here} -- (3,1) node[right]{to here};
\end{tikzpicture}

\end{document}

You just need to add the marked two lines to your TeX file to get larger arrow heads. The size is controlled by the two parameters width and length. For the above example, the output is as follows: output of the arrow example

There is a variety of arrow styles to choose from; the style used in the example is called Latex. Examples of relatively plain arrow styles include Stealth, Straight Barb and Computer Modern Rightarrow; any of these arrow styles can be used by replacing Latex in the above example with the corresponding style name. See the other answers and section 16.5 "Reference: Arrow Tips" of the TikZ and PGF manual for a complete list of available arrow styles.

share|improve this answer
1  
arrows.meta library is actually the accepted answer converted into an official library. Luigi is/was involved in the conversion. You can see the note in his answer too. –  percusse Mar 22 at 12:32
    
@percusse, this is good to know! (I wrote a separate answer just because with all the information provided in the other answers, I struggled a bit to know what I should actually copy/paste into my TeX file.) –  jochen Mar 24 at 17:13

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.