TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

I want to put an arrow head at the middle of an arc. Unfortunately, ArrowInside is not available for \psarc. The possible way is to construct it with 2 arcs as follows. Leaving arcsepB with its default value will produce a weird effect, that is why I have to set arcsepB to a negative length.

I hate a trial and error approach to get the best value for it. I believe there is a formula to exactly specify the maximum value for it.

enter image description here

\psarc[arrowscale=2,arcsepB=\n pt]{->}(0,0){3}{0}{45}
\rput(1.5,1.5){\n pt}

Is there a formula to determine the maximum value arcsepB such that the arrow head looks best?

The following is taken from PSTricks documentation (use texdoc pstricks), it might be useful for you.

enter image description here

With an elementary geometry (as opposed to differential geometry or topology), I should find the formula.

share|improve this question
I think you have to take back the arrow head and let the line join close the curve so I would go with a negative inset that is equal to -arrowlength. Otherwise the arrow head would be placed a little rotated since it would be trying to follow the curve as barely visible in your another fantastic animation. (It's turning slightly CCW which is more than the tangent angle). That might on the other hand turn it wrongly in the other direction. – percusse Oct 19 '12 at 13:58
@percusse: it will be easier to understand if you provide me with a real code as opposed the sentences. – kiss my armpit Oct 19 '12 at 15:28
Hmmm, it seems my bounty to be too small to stimulate you.... I will increase it for the next bounty. – kiss my armpit Oct 25 '12 at 4:53
No, I just don't know enough PSTricks. – percusse Oct 25 '12 at 8:43
In fact you're just looking for a formula to calculate the extra length for the arc? As far as i know arrowlength=(length of arrow)/(width of arrow)=(extra length of arc)/(width of arc)... so extra length of arc = (width of arc)*arrowlength? In this case 5\pslinewidth*1.4, so 7\pslinewidth? – long tom Oct 25 '12 at 20:36
up vote 4 down vote accepted

I have three solutions ludicrous attempts for you:

  1. a graphical/geometrical which I actually think is right,
  2. a mathematically “precise” equation (probably not correct),
  3. a approximation of the second point (surely wrong).

1. The geometry

enter image description here

The solution seems near, we only have to solve for t1.

Why is arcsepB the way I sketched it? The PSTricks manual states:

angleB is adjusted so that the arc would just touch a line of width dim that extended from the center of the arc in the direction of angleB.

2. The “precise” equation

I used the vector from A to B to get an equation that is only expressed in terms of t1. This is what I got:

enter image description here

It looks good, but even a numerical approximation to solve this equation didn’t yield any results. (A previous version of this equation did however, but did not correspond to TikZ’ result.)

3. The approximation

The following steps required some trigonometric approximations that are only valid for small angles of t1, which is true for big arrows and relevantly small line widths (the sketch is out of proportions).

I finally got to a simple quadratic equation that is solvable but—in this case—not in ℝ. (The radicand is lower than zero.)

enter image description here

The whole document and derivation


% some lengths

% PSTricks variables
\pgfmathsetlength\dimRadius{.5cm}%                    see MWE
\pgfmathsetlength\dimLinewidth{4pt}%                  see MWE, 5 * \pstlinewidth = 5 * .8pt
\pgfmathsetlength\dimArrowsize{1.5pt}%                see PSTricks manual
\newcommand*{\numArrowsize}{2}%                       see PSTricks manual
\newcommand*{\numArrowlength}{1.4}%                   see PSTricks manual
\newcommand*{\numArrowinset}{0.4}%                    see PSTricks manual
\newcommand*{\numArrowscale}{2}%                      see MWE
% set random

% result
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\pgfmathsetlength\arWidth{\numArrowscale*(\numArrowsize*\dimLinewidth+\dimArrowsize)}% see PSTricks manual
\pgfmathsetlength\arLength{\arWidth*\numArrowlength}% see PSTricks manual
\pgfmathsetlength\arInset{\arLength*\numArrowinset}%  see PSTricks manual

\fill[black!20] (\angStart:\dimRadius+\dimLinewidth/2) arc[radius = \dimRadius+\dimLinewidth/2, start angle=\angStart, end angle=\angEnd] --
              (\angEnd:\dimRadius-\dimLinewidth/2) arc[radius = \dimRadius-\dimLinewidth/2, start angle=\angEnd, end angle=\angStart] -- cycle;

\draw[name path=middle line, thin, dashdotted] (0:\dimRadius)                 arc[radius = \dimRadius,                 start angle=\angStart, end angle=\angEnd];
\draw[name path=outer line,  thin]             (0:\dimRadius+\dimLinewidth/2) arc[radius = \dimRadius+\dimLinewidth/2, start angle=\angStart, end angle=\angEnd];
\draw[name path=inner line,  thin]             (0:\dimRadius-\dimLinewidth/2) arc[radius = \dimRadius-\dimLinewidth/2, start angle=\angStart, end angle=\angEnd];

\draw[name path global=arrow, blue, fill=blue, fill opacity=.2, line join=round]
    (\angUntip:\dimRadius) coordinate (D) -- (\angTip:\dimRadius) coordinate (A) -- ++ (
    ) -- cycle;
\fill[name intersections={of=arrow and outer line}, red] (intersection-1) coordinate (B);
\path[name path=radius to B] (B) -- (0,0);
\fill[name intersections={of=radius to B and middle line}, red] (intersection-1) coordinate (C);
\draw[gray] (B) -- (C);% half linewidth

\draw[name path global=continuous of C, ultra thin] let \p1=(C), \n1={atan2(\x1,\y1)} in (C) -- +(\n1+90:1) \pgfextra{\xdef\angArcEnd{\n1}};
\draw[name path global=rect of A,       ultra thin] (A) -- + (\angArcEnd:1);
\fill[name intersections={of=continuous of C and rect of A}, red] (intersection-1) coordinate (E);

\draw [green] let \p1 = (C), \p2 = (E), \n1 = {veclen(\x2-\x1,\y2-\y1)} in 
    (C) -- (E);

\draw [green,opacity=.5] (A) -- + (\angArcEnd-90:\arcsepB);
\draw[gray] (0,0) -- (\angStart:\dimRadius)
            (0,0) -- (C)
            (0,0) -- (A)
            (0,0) -- (D);

\draw (\angStart:.31\dimRadius) arc [radius=.31\dimRadius, start angle=\angStart, end angle=\angArcEnd] node at ({(\angArcEnd+\angStart)/2}:.2\dimRadius) {\(t_0\)};
\draw (\angArcEnd:.3\dimRadius) arc [radius=.3\dimRadius, start angle=\angArcEnd, end angle=\angTip] node at ({(\angTip+\angArcEnd)/2}:.2\dimRadius) {\(t_1\)};
\draw ($(A)!.3\dimRadius!(D)$) arc [radius=.3\dimRadius, start angle=\arDirection-180, end angle=\arDirection-(180-\angBeta)] node[shift={({(\arDirection-180+\arDirection-(180-\angBeta))/2}:.2\dimRadius*\tikzScale)}] at (A) {\(\beta\)};
\draw let \p1 = (D), \n1={atan2(\x1,\y1)} in
      (\n1:.33\dimRadius) arc [radius=.33\dimRadius, start angle=\n1, end angle=\angArcEnd] node at ({(\n1+\angArcEnd)/2}:.4\dimRadius) {\(t_2\)};
\draw (\angUntip:.7\dimRadius) arc[radius=.3\dimRadius, start angle=\angUntip+180, end angle=\arDirection] node[shift={({(\angUntip+180+\arDirection)/2}:.2\dimRadius*\tikzScale)}] at (D) {$\alpha$};
\draw (D) -- + (0:.35\dimRadius);
\draw ([xshift=.3\dimRadius]D) arc[radius=.3\dimRadius, start angle=0, end angle=\arDirection] node[shift={(\arDirection/2:.2\dimRadius*\tikzScale)}] at (D) {$\gamma$};
\draw[decorate] (D) -- node[sloped,below] {\(\larrow-\iarrow\)} (A);
\draw[decorate] (E) -- node[sloped,above] {\(\mathtt{arcsepB} = \pgfmathprintnumber{\arcsepBwithoutpt}\,\textrm{pt} \)} (C);

\foreach \p/\pos in {A/left,B/above,C/below,D/below,E/left} {
    \fill[red] (\p) circle (.5pt/\tikzScale);
%   \begin{pgfonlayer}{background}
        \expandafter\node\expandafter[\pos,red!75!black] (n\p) at (\p) {$\p$};
%   \end{pgfonlayer}
%\node at (90:1cm) {\the\dimLinewidth};
\caption{We're looking for $t_1$. $\beta = \radBeta\,\textrm{rad}$, $\wline = \strippt{\dimLinewidth}\pt$, $r = \strippt{\dimRadius}\pt$, $\larrow = \strippt{\arLength}\pt$, $\iarrow = \strippt{\arInset}\pt$}

\section{Our Goal}
First things first, $\mathtt{arcsepB}$ can be calculated by
    \mathtt{arcsepB} = r\sin t_1 \label{eq:goal}

\section{What do we know?}
But before we begin, let us define some points:
 \vect{A} & = r \begin{pmatrix}
                    \cos(t_0+t_1) \\
                \end{pmatrix}                   \\
 \vect{B} & = \left(r+\frac{\wline}2\right) \begin{pmatrix}
                                                     \cos t_0 \\
                                                     \sin t_0
                                                 \end{pmatrix}   \\
 \vect{D} & = r \begin{pmatrix}
                    \cos(t_0-t_2) \\

Geometry does also teach us:
    l\sub{arrow} - \iarrow & = 2 r \sin(t_1 + t_2) \\
    t_2 & = \arcsin \left(\frac{\larrow-\iarrow}{2r}\right) - t_1 \label{eq:aux:t2} \end{split}\\
    \tan \beta & =  \frac{w\sub{arrow}}{2 \, \larrow} \label{eq:aux:beta}

The angle $\alpha$ can be calculated by
    \alpha = \frac{\pi-(t_1+t_2)}{2}.

The direction of the arrow $\gamma$ (from $\vect{D}$ to $\vect{A}$) and $\gamma'$ (from $\vect{A}$ to $\vect{D}$) is
        \gamma & = t_0 - t_2 + \pi - \alpha \\[\jot] \shortintertext{and}
        \gamma' & = \gamma \pm \pi = t_0 - t_2 - \alpha \\
                & = t_0 + \frac{t_1-t_2}{2} - \frac{\pi}{2}

How do we get from $\vect{A}$ to $\vect{B}$?
    \vect{B} = \vect{A} + \tau \begin{pmatrix} \cos(\gamma'+\beta) \\ \sin(\gamma'+\beta) \end{pmatrix}

As we can safely set $t_0=0$ as $t_0$ does only describe a rotation, with \cref{eq:start} inserted in \cref{eq:AtoB} we get the following two equations.
    r + \frac{\wline}{2} & = r\cos t_1 + \tau \cos(\gamma'+\beta) \label{eq:system:a}\\
    0 & = r \sin t_1 + \tau  \sin(\gamma'+\beta) \label{eq:system:b}
    \intertext{We can insert \cref{eq:system:b} in \cref{eq:system:a} eliminating $\tau$ and after dividing through $r$ we get}
    1 + \frac{\wline}{2r} & = \cos t_1 - \sin t_1 \frac{\cos(\gamma'+\beta)}{\sin(\gamma'+\beta)} \\
    1 + \frac{\wline}{2r} & = \cos t_1 - \sin t_1 \cot\left(\frac{t_1-t_2}{2} - \frac{\pi}{2} + \beta\right) \label{eq:notyetfinal}

What follows now are some trigonometric formulae.
    \cos x & = \sqrt{1-\sin^2x} \label{eq:sincos}\\
    \sin\left(x+\frac{\pi}{2}\right) & = \cos x \\ \cos\left(x+\frac{\pi}{2}\right) & = - \sin x \\
    \cot\left(x+\frac{\pi}{2}\right) = \frac{\cos\left(x+\frac{\pi}{2}\right)}{\sin\left(x+\frac{\pi}{2}\right)} &
    = - \frac{\sin x}{\cos x} = - \tan x \\
    \intertext{with $x=x'-\pi$ we get}
    \cot\left(x'-\frac{\pi}{2}\right) & = - \tan(x'-\pi) \\ & = \tan x' \label{eq:cottan} \end{split}\\ \intertext{as well as}
    \tan (x + y) & = \frac{ \tan x + \tan y }{ 1 - \tan x \cdot \tan y } \label{eq:tantan}

With \cref{eq:cottan} substituted in \cref{eq:notyetfinal} we can say that
    1 + \frac{\wline}{2r}  = \cos t_1 - \sin t_1 \tan\left(\frac{t_1-t_2}{2} + \beta\right) \label{eq:stillnotfinal}
\Cref{eq:stillnotfinal} can further ``simplified'' with \cref{eq:aux:t2} to
    1 + \frac{\wline}{2r} = \cos t_1 - \sin t_1 \tan \left[
        t_1 + \beta - \arcsin \left(\frac{\larrow-\iarrow}{2r} \right)\right] \label{eq:halfgoal}

At this point, the whole \cref{eq:halfgoal} does only have one unknown variable: $t_1$.

\Cref{eq:halfgoal} with \cref{eq:tantan}:
    1 + \frac{\wline}{2r} = \cos t_1 - \sin t_1 \frac{\tan t_1 + \tan\left(\beta - \arcsin \left(\frac{\larrow-\iarrow}{2r} \right)\right)}{1-\tan t_1 \tan \left(\beta - \arcsin \left(\frac{\larrow-\iarrow}{2r} \right)\right)} \label{eq:notquiteyet}

In \cref{eq:notquiteyet} we do the following substitutions.
Following \cref{eq:system:b} we can be satisfied with $\sin t_1$:
    \sin t_1 & = t' \\
    \shortintertext{For small angles:}
    \tan t_1 & \approx \sin t_1 = t' \\
    \cos t_1 & = 1 \\
    \cos t_1 & = \sqrt{\smash[b]{1-\sin^2t_1}} = 1 \quad \text{(See \cref{eq:sincos}.)} \\
    \tan \left(\beta - \arcsin \left(\frac{\larrow-\iarrow}{2r} \right)\right) & = u 
    = \pgfmathresult\pt

With the \cref{eq:subs} we get for \cref{eq:notquiteyet}:
    1 + \frac{\wline}{2r} & = 1 - t' \frac{t'+u}{1-ut'} \\
    \frac{\wline}{2r} - \frac{u\wline}{2r} t' & = - {t'}^2 - u t' \\
    {t'}^2 + \left(u-\frac{u\wline}{2r}\right)t' + \frac{\wline}{2r} & = 0 \label{eq:quadratic}

The solution of \cref{eq:quadratic} is
    t'_{1,2} = \frac{u\wline}{4r} - \frac{u}{2} \pm \sqrt{\frac{u^2\wline^2}{16r^2}-\frac{u^2\wline}{4r}+\frac{u^2}{4}-\frac{w}{2r}}


Well, I messed up. Even a numerical solution of the (thought-to-be) precise equation is not possible, which must mean that somewhere along the path to that equation I have must encountered an error.

share|improve this answer
Temporarily I accept this answer even though I have not checked it yet (as I am too busy to do something). Your effort looks well-considered! Thank you! – kiss my armpit Dec 25 '12 at 7:06
@GarbageCollector Thanks, but I have gotten us nowhere. ;) (And going over it now I see already that I have missed an factor of 1/2.) I am sure that some people either see my errors or better yet come up with an easier solution. – Qrrbrbirlbel Dec 25 '12 at 7:10
@Qrrbrbirlbel in (3a): l_{arrow}-i_{arrow}=2r*sin[(t_1+t_2)/2], however it seems to me that eq. 10 is correct. With your values, I get t_1 ≈ 2.241676671, hence arcsepB ≈ 11.14. – Luigi Dec 27 '12 at 16:24

draw the complete arc first and then the arrow or use a simple \psline with polar coordinates:





enter image description here

share|improve this answer
Unless there is such a formula, I will happily accept this answer. – kiss my armpit Oct 28 '12 at 13:24

Herbert's answer is probably the most simple and should be preferred. As the problem is interesting from a mathematical point of view, I just wanted to sketch some mathematical solution, as it might be interesting for someone.

Let's first assume, that the radius of your arc (circle) is very large compared to its line width (infinitely large, otherwise see later). Then, the arrow has to be shifted "to the front". You can find out how large the shift is by using the intercept theorem. In your case it's scaling the arrow length by the width ratio, i.e.,

shift = arrowLength * lineWidth / arrowWidth.

The remaining question is: How much is a shift forward in angle? This obviously depends on the radius. Using a similar idea as above leads to

shift / (2 * pi * radius) = shiftAngle / 360°.

So all in all you get

shiftAngle = (arrowLength * lineWidth * 360°) / (2 * pi * radius * arrowWidth).

This is all fine, but what if the arc is not very large compared to the line width? One additional problem (there might be more, depending on the implementation in pstricks) is, that the line does not have one radius due to its linewidth, but at least a center radius, an inner radius and an outer radius. To be on the save side, you could always shift by the inner radius, as this will lead to the largest shiftAngle.

share|improve this answer
the radius also depends to the dimen setting: inner, outer, or middle – Herbert Nov 1 '12 at 8:53
Can you apply your calculation to a complete code? – kiss my armpit Nov 3 '12 at 20:02
Sorry, but I lack the pstricks knowledge to do something useful here, so I better skip it before I mislead someone. As written, the other answers are the way to go, I just wanted to give a hint for the mathematics. – Patrick Häcker Dec 19 '12 at 20:35

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.