2

I am attempting to learn Tikz via this MIT tutorial. Early in the tutorial the author provides the following code:

\draw[help lines, thick] (0,0) grid (4,4);
\draw[->,>=diamond,thick] (0,0) -- (1,2);

Question:

The >=diamond part of the second \draw command is causing

! Package pgf Error: Unknown arrow tip kind 'diamond'

Why is this happening?

Torbjørn T.
  • 206,688
Gary
  • 371
  • I woult put this as a comment but I don't have enough reputation points: If the Tikz manual seems daunting at first (although it’s less daunting than it looks) Overleaf has some pretty good tutorials as an introduction. There is this one, which is a general tutorial, there’s also this, which is a 5 part series, and [this one](https://www.overleaf.com/ – Devano Bethel Aug 02 '22 at 21:43

1 Answers1

11

Because TikZ by default doesn't define an arrow tip named diamond.

To access the diamond tip you need to load the now deprecated library arrows. However, because that library is considered deprecated, I'd instead load the arrows.meta library, and use the Diamond tip.

\documentclass{article}
\usepackage{tikz} 
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw[help lines, thick] (0,0) grid (4,4);
\draw[->,>=Diamond,thick] (0,0) -- (1,2);
\end{tikzpicture}
\end{document}
Torbjørn T.
  • 206,688
  • Thanks! Do you have any recommendations for an up-to-date general Tikz tutorial? – Gary Aug 02 '22 at 18:03
  • 2
    @Gary I don't really know what's out there, so can only suggest chapters 2-6 of the TikZ manual. – Torbjørn T. Aug 02 '22 at 18:04
  • 1
    @Gary: The way to learn TikZ is to read the manual. The manual is huge, but it is well structured. You only need to read what is relevant for a specific drawing. There is even a tutorial/introduction directly in the manual. – hpekristiansen Aug 02 '22 at 18:55
  • With arrows.meta, you can write \draw[-{Diamond},thick] for something more compact. – Crazymoomin Aug 03 '22 at 10:13
  • @Crazymoomin The -arrowtipname syntax doesn't require arrows.meta, if that's what you meant. And if you'll forgive some further nitpicking, the {} are only needed if you add options in [] to the arrow tip. :) – Torbjørn T. Aug 03 '22 at 12:57
  • 1
    @TorbjørnT. I know about the second one, I think it's just a good habit to keep them because you'll forget when you do add options! – Crazymoomin Aug 04 '22 at 13:10