0

When I draw paths:

 \path [draw=blue] 
 (0,0) 
 arc(-60:60:1.732) 
 arc(120:240:1.732);

I want to add an arrow in the middle of each arc within this \path.

Like this:

enter image description here

I have tried the "show path construction" (curveto code) style in the package decorations.pathreplacing. However It doesn't create decoration on each arc, but every 90 degrees (or less than 90 degrees). This is because the "curveto code" in "show path construction" create decorations for each Bezier curve, and one circle is created by 4 Bezier curves.

3

First of all, I want to tell you that using only one \path throughout the picture is not recommended, and you should really use as many \paths as possible if there are different types of lines drawn.

If you want to compress many lines to a single \path, you need something like the edge operation. Unfortunately, edge doesn't accept arc or similar as its option, so I use out and in here. Therefore, the output curves are not exactly the curves in some circles. I hope it is close enough.

I also made some developments to middlearrow style in ferahfeza's nice answer, so that it can handle the nodes.

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\tikzset{
    middlearrow/.style n args={3}{
        draw,
        decoration={
            markings,
            mark=at position 0.5 with {
                \arrow{#1};
                \path[#2] node {$#3$};
            },
        },
        postaction=decorate
    }
}
\begin{document}
\begin{tikzpicture}[>=stealth]
\coordinate (x) at (0,0);
\coordinate (y) at (0,3);
\path (x)   edge[out=60,in=-60,middlearrow={<}{left}{b}] (y)
            edge[out=30,in=-30,middlearrow={>}{right}{s}] (y)
            edge[out=120,in=-120,middlearrow={<}{right}{a}] (y)
            edge[out=150,in=-150,middlearrow={>}{left}{r}] (y);
\end{tikzpicture}
\end{document}

enter image description here

  • Thank you very much JouleV! Yes, edge works very well. Sometimes I use edge to draw some illustrative diagrams when accurate controlling is not necessary. In some cases, I need accurate length and angles of arcs (with middle arrows on them). – Frank Apr 13 at 17:42
  • Previously I mainly used the second solution under this question: tex.stackexchange.com/questions/3161/…, but it will add more than one arrow when the angles of arcs are greater than 90. The reason is that, as I said in the description of the question, the number of arrows is determined by the number of Bezier curves. If the angle of an arc greater than 90, at least two Bezier curves is used to create the arc. – Frank Apr 13 at 17:42
  • @Frank Of course you can choose anything you want. This is only my proposal. – user156344 Apr 13 at 17:44
  • Thank you for the solution. I really apreciate your effort. Thanks! – Frank Apr 13 at 17:46
2

Define \path for each arc.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
% Middlearrow code is from:
% https://tex.stackexchange.com/a/39283
\tikzset{middlearrow/.style={
        decoration={markings,
            mark= at position 0.5 with {\arrow{#1}} ,
        },
        postaction={decorate}
    }
}

\begin{tikzpicture}[line width=0.5mm,>=stealth]
 \path [draw=blue,middlearrow={>}] 
 (0,0) 
 arc(-60:60:1.732)coordinate (A) node[midway,right,yshift=-1mm]{$s$} ;

\path [draw=blue,middlearrow={<}] 
 (0,0) 
 arc(-30:30:3)node[midway,left,yshift=-0.75mm]{$b$};

 \path [draw=blue,middlearrow={>}] 
 (0,0) 
 arc(240:120:1.732)node[midway,left,yshift=-1mm]{$r$} ;

 \path [draw=blue,middlearrow={<}] 
 (0,0) 
 arc(210:150:3)node[midway,right,yshift=-1mm]{$a$} ;

\fill [blue] (0,0) circle (2pt);
\fill [blue] (A) circle (2pt);
\end{tikzpicture}
\end{document}

enter image description here

  • Thank you very much! Is there any other solution which needs only one \path? I want to use relative coordinates to draw arcs. – Frank Apr 13 at 10:13
  • @Frank What do you mean by "relative coordinates"? Is two paths solution ok, because there are two types of arrow? Moreover, why do you want only one path? Four paths cost you nothing at all. – user156344 Apr 13 at 11:45
  • @JouleV I mean I may use say two or more arcs in one path, with each arc connected end to end, and each decorated by an arrow. The two path solution is OK. Thank you for your reply. – Frank Apr 13 at 12:03

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.