Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
You should add \usetikzlibrary{arrows} in your MWE. See question is-it-possible-to-change-size-of-arrowhead-in-tikz-pgf. –  Kurt Sep 24 '12 at 12:51
    
Nice! But I though that this arrow was on the predefined ones. –  Sigur Sep 24 '12 at 12:55
add comment

1 Answer

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

share|improve this answer
    
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 '12 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 '12 at 14:24
    
Sure I am trying to write it in code format –  Matteo Sep 24 '12 at 14:36
    
You can always edit your first question to add such precisions. –  T. Verron Sep 24 '12 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 '12 at 14:47
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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