10

I would like to use lines with arrowheads in a Tikz drawing. The lines should have different thicknesses/widths, like so:

Arrows with different line widths

Another answer here pointed out the line width attribute to modify the width of a line in Tikz. I have tried this in a small example document:

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw[-latex,line width=1mm] (0,0) -- (5,0);
\draw[-latex,line width=2mm] (0,1.5) -- (5,1.5);
\draw[-latex,line width=3mm] (0,3) -- (5,3);
\draw[-latex,line width=4mm] (0,4.5) -- (5,4.5);
\draw[-latex,line width=5mm] (0,6) -- (5,6);
\draw[-latex,line width=6mm] (0,7.5) -- (5,7.5);
\draw[-latex,line width=7mm] (0,9) -- (5,9);
\end{tikzpicture}

\end{document}

Unfortunately, for some reason, Tikz also scales up the arrowhead when using line width:

Arrows with different line widths and different arrowhead sizes

How can I suppress this behaviour and force Tikz stick with a fixed arrowhead size across all line thicknesses?

There does not seem to be an arrowhead size attribute, as far as I can see in the manual (?)

EDIT: For clarification, I am not looking for a way to set an arrowhead size on a per-line basis. I am looking for a way to set an absolute arrowhead size for a whole Tikz picture, which will then apply to all lines of a certain style, no matter which width they have (the width being set on a per-line basis!).

2
  • @c.p.: In the first question, something about the arrows still seems to depend on the line width, and especially for thicker lines, I seem to be getting only weird blobs (even when setting different scale values for lines of different thicknesses, which is what I would generally like to avoid for uniform arrowheads). Commented Aug 17, 2015 at 12:12
  • @c.p.: One of the answers in the second link sounds promising - regrettably, it only works for oversized arrows (compared to the line), not undersized ones. Note, however, that both questions aren't quite the same as here - I am specifically looking for reusing one particular arrow style several times, irrespective of line width. Individually dapting the arrow size for each line is a workaround at best in my question, while it is a fully valid solution for the linked questions that ask for actively resizing the arrowheads. Commented Aug 17, 2015 at 12:15

1 Answer 1

11

You can use the library arrows.meta and explicitly state the length and width or the arrows. You can do this for the entire picture, once - no need to do it for each individual case.

\documentclass[tikz,border=20pt]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[>={LaTeX[width=10mm,length=10mm]},->]
  \draw[line width=1mm] (0,0) -- (5,0);
  \draw[line width=2mm] (0,1.5) -- (5,1.5);
  \draw[line width=3mm] (0,3) -- (5,3);
  \draw[line width=4mm] (0,4.5) -- (5,4.5);
  \draw[line width=5mm] (0,6) -- (5,6);
  \draw[line width=6mm] (0,7.5) -- (5,7.5);
  \draw[line width=7mm] (0,9) -- (5,9);
\end{tikzpicture}
\end{document}

explicit length and width for arrows

Use Triangle rather than LaTeX for triangular tips:

Triangular variation

8
  • On its own, this seems to work. Unfortunately, it appears to get into a conflict with the Tikz-based edge definitions from Tikz-uml, which I am also trying to use in the same document. I will have to check whether I can replace Tikz-uml somehow. +1 for now, anyway. Commented Aug 17, 2015 at 12:34
  • I ended up dropping tikz-uml in favour of being able to use this solution and drawing my UML diagrams with Dia. Commented Aug 18, 2015 at 8:02
  • @O.R.Mapper Hmmm. I don't know much about that package as I don't think I've ever used it. I'm glad you found a workaround. An alternative would be to create some diagrams separately in something like standalone and then include them using \includegraphics. It is a shame about the conflict, though. If you wanted to follow up, I'd recommend asking a new question specifically about that.
    – cfr
    Commented Aug 18, 2015 at 12:36
  • @O.R.Mapper I downloaded the package to experiment and got errors. However, I get errors even if I just try to compile the example document I was testing which is provided by the package. So presumably I'm missing something essential in how to set this up ;).
    – cfr
    Commented Aug 18, 2015 at 12:57
  • It worked for me when just using the tikz-uml package. I will consider adding a separate question on that issue. Commented Aug 18, 2015 at 13:23

You must log in to answer this question.

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