4

I'm working with Tikz package and I want to create a new arrow tip. So I used the following code which I found in internet:

\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

% Code for the new arrow tip, called halfcirc.
\pgfarrowsdeclare{halfcirc}{halfcirc}
{
\arrowsize=0.2pt
\advance\arrowsize by .5\pgflinewidth
\pgfarrowsleftextend{-4\arrowsize-.5\pgflinewidth}
\pgfarrowsrightextend{.5\pgflinewidth}
}
{
\arrowsize=0.2pt
\advance\arrowsize by .5\pgflinewidth
\pgfsetdash{}{0pt} % do not dash
\pgfsetroundjoin % fix join
\pgfsetroundcap % fix cap
\pgfpathmoveto{\pgfpoint{-4\arrowsize}{4\arrowsize}}
\pgfpatharc{90}{-90}{4\arrowsize}
\pgfusepathqstroke
}

% Declare a reversed version called revhalfcirc.
\pgfarrowsdeclarereversed{revhalfcirc}{revhalfcirc}{halfcirc}{halfcirc}

% Demonstration of the arrow tip.
\begin{tikzpicture}
\draw[help lines] (-3,-2) grid (3,2);
\draw[line width=10pt, revhalfcirc-halfcirc] (-2,0) -- (0,0);
\end{tikzpicture}

\end{document}

But an error pops up:

! Undefined control sequence.
\pgf@arrow@right@revhalfcirc -> \arrowsize 
                                           =0.2pt \advance \arrowsize by .5\...
l.32 ...pt, revhalfcirc-halfcirc] (-2,0) -- (0,0);

? 

What is the problem? I am a beginner in using Tikz.

1
  • Nice! But I though that this arrow was on the predefined ones.
    – Sigur
    Sep 24, 2012 at 12:55

1 Answer 1

6

You need to load the tikz library providing support for arrows and such, by adding

\usetikzlibrary{arrows}

just below your call to the tikz package. This library then provides the \arrowsize command and others.

In your example, the code should look like :

\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

% Code for the new arrow tip, called halfcirc.
\pgfarrowsdeclare{halfcirc}{halfcirc}
{
\arrowsize=0.2pt
\advance\arrowsize by .5\pgflinewidth
\pgfarrowsleftextend{-4\arrowsize-.5\pgflinewidth}
\pgfarrowsrightextend{.5\pgflinewidth}
}
{
\arrowsize=0.2pt
\advance\arrowsize by .5\pgflinewidth
\pgfsetdash{}{0pt} % do not dash
\pgfsetroundjoin % fix join
\pgfsetroundcap % fix cap
\pgfpathmoveto{\pgfpoint{-4\arrowsize}{4\arrowsize}}
\pgfpatharc{90}{-90}{4\arrowsize}
\pgfusepathqstroke
}

% Declare a reversed version called revhalfcirc.
\pgfarrowsdeclarereversed{revhalfcirc}{revhalfcirc}{halfcirc}{halfcirc}

% Demonstration of the arrow tip.
\begin{tikzpicture}
\draw[help lines] (-3,-2) grid (3,2);
\draw[line width=10pt, revhalfcirc-halfcirc] (-2,0) -- (0,0);
\end{tikzpicture}

\end{document}

Compiled, it gives the following output, which seems to be what you expect : Output

7
  • Hello! Thanks for the reply. I still get the same error: ! Undefined control sequence.\pgf@arrow@right@revhalfcirc -> \arrowsize =0.2pt \advance \arrowsize by .5\... l.32 ...pt, revhalfcirc-halfcirc] (-2,0) -- (0,0); ? I don't get why..
    – Matteo
    Sep 24, 2012 at 14:22
  • That's strange, I tried it before posting and it worked like a charm. Could you update your MWE so that we can see what's going on?
    – T. Verron
    Sep 24, 2012 at 14:24
  • Sure I am trying to write it in code format
    – Matteo
    Sep 24, 2012 at 14:36
  • You can always edit your first question to add such precisions.
    – T. Verron
    Sep 24, 2012 at 14:41
  • I can t manage to copy it, but it is exactly the same as I wrote above, but adding \usetikzlibrary{arrows} just below \usepackage{tikz}
    – Matteo
    Sep 24, 2012 at 14:47

You must log in to answer this question.

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