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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I want to draw a curve with an arrow somewhere along its length (say 40% along), I can write this:

\draw [decoration={
             mark=at position 0.4 with \arrow{>}}
       (A) to (B);

If I want to draw lots of curves with the same decoration, I can put most of this in a scope and reduce how much I have to type for each path.

However, if I want to draw lots of curves with different parameters - say, each one needs to have the arrow at a different position, and the choice of < or > could vary between curves. Then it seems I have a lot of typing to do for each curve.

What I'd like to do is define something like this:

             mark=at position #1 with \arrow{#2}}

Then I can draw my arrows with ease:

\draw [\arrowdata{0.3}{>}] (A) to (B);
\draw [\arrowdata{0.95}{<}] (C) to (D) to (E);

and so on. But, this doesn't work, and I don't understand the error messages that result. Clearly I'm being too naive in my understanding of how macros apply in TikZ. Can someone help me out?

share|improve this question
up vote 10 down vote accepted

Macros in style definitions don't work if they aren't expanded beforehand. You should define your own style instead.

\tikzset{arrow data/.style 2 args={%
         mark=at position #1 with \arrow{#2}},

The use it like:

\draw [arrow data={0.3}{>}] (A) to (B);
share|improve this answer

Your Answer


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.