7

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

0

1 Answer 1

10

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.

2
  • If this node is aligned to the rectangular node then it is visible the difference between the sizes of these nodes - it equals one width of the line.
    – forrest
    Commented Jun 14, 2019 at 7:27
  • 1
    @forrest Yes, there are actually two reasons why the arrow does not fit the rectangle. One is, as you mentioned, the finite line width (which increases both the width and length of the arrow). The other is the effect of the miter line join. I'll update the answer with a fat arrow to show the effect of both. The former could be solved by subtracting the line width (0.4pt for the default thin line), the latter by switching to a round or bevel line join. Commented Jun 14, 2019 at 8:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .