How to adjust arrow head size of arrow-node?

by forrest   Last Updated June 13, 2019 08:23 AM

I am trying to use single arrow node from shapes.arrows TikZ library. The problem is with the proper adjustment of the arrow tip span - with the argument single arrow head extend. MWE:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}
\begin{document}
\begin{tikzpicture}
    \node [single arrow,draw,inner sep=0,minimum width=2cm,minimum height=2cm,single arrow head extend=0.2cm] {};
\end{tikzpicture}
\end{document}

enter image description here



Answers 1


Combining minimum width with single arrow head extend seems buggy. Use inner sep instead to define the inner width:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}
\begin{document}
\begin{tikzpicture}
    \node [single arrow,draw,inner sep=1cm,minimum height=4cm, single arrow head extend=0.8cm,anchor=west] (a) {};
    \draw[|<->|, purple, ultra thin] (0,0) -- (4,0) node [midway, above, sloped] {\tiny 4 cm};
    \draw[|<->|, red, ultra thin] (0,0) -- (0,1) node [midway, above, sloped] {\tiny 1 cm};
    \draw[|<->|, blue, ultra thin] (a.before head) -- ++(0,0.8) node [midway, above, sloped] {\tiny 0.8 cm};
\end{tikzpicture}
\end{document}

arrowheadsized

Update: the final size of the arrow could still be larger than intended, as caused by the finite line width and default miter line join option, illustrated below.

\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}
\begin{document}
\begin{tikzpicture}
    \tikzset{samplearrow/.style={single arrow,draw,inner sep=1cm,minimum height=4cm, single arrow head extend=0.8cm,anchor=west,line width=5mm}}
    \node [samplearrow, orange!50] (a) {};
    \node [samplearrow, gray,line join=round] (b) {};
    \draw[|<->|, purple, ultra thin] (0.5,0) -- ++(4,0) node [midway, above, sloped] {\tiny 4 cm};
    \draw[|<->|, red, ultra thin] (0,0) -- (0,1) node [midway, above, sloped] {\tiny 1 cm};
    \draw[|<->|, blue, ultra thin] (a.before head) -- ++(0,0.8) node [midway, above, sloped] {\tiny 0.8 cm};
    \draw[|<->|, ultra thin] (0,1) -- ++(0,0.5) node [midway, above, sloped] {\tiny 5 mm};
    \draw[|<->|, ultra thin] (0,0) -- (0.5,0) node [pos=0, left, sloped] {\tiny 5 mm};
    \draw[<-,orange] (a.before tip) -- ++(-0.2,0) node[left] {\tiny miter};
\end{tikzpicture}
\end{document}

fatarrowheadsized

This could be solved by subtracting the line width from both the inner sep and minimum height (e.g. inner sep=1cm-0.4pt for the default case of using a thin line), and by setting line join to round (as illustrated in gray) or bevel.

JJM Driessen
JJM Driessen
June 13, 2019 09:12 AM

Related Questions


Updated September 15, 2017 18:23 PM

Updated December 03, 2016 08:09 AM

Updated February 25, 2019 14:23 PM

Updated March 16, 2017 15:23 PM

Updated March 29, 2017 23:23 PM