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?

1
  • 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](overleaf.com Aug 2 at 21:43

1 Answer 1

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}
6
  • Thanks! Do you have any recommendations for an up-to-date general Tikz tutorial?
    – Gary
    Aug 2 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. Aug 2 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. Aug 2 at 18:55
  • With arrows.meta, you can write \draw[-{Diamond},thick] for something more compact. Aug 3 at 10:13
  • 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! Aug 4 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.