0

How to set different arrow position for different closed path, i.e. the small circle and the semi-circle?

I add the arrow setting in the beginning of the environment and obviously it applies to all paths.

\begin{tikzpicture}[>={Latex[length=0.15cm, bend]},
    decoration={markings,
    mark= at position .2 with {\arrow{>}},
    mark= at position .8 with {\arrow{>}},
    }]
\def\bigradius{1.3}

% contour \filldraw[postaction = {decorate}, thick ,fill=gray!20] (-\bigradius, 0) node[yshift=-8pt]{$R$} arc (180:0:\bigradius) node[yshift=-8pt]{$-R$} -- (\bigradius, 0) -- cycle; \filldraw[postaction = {decorate}, thick, fill=white] (0, 0.6) circle (3.8mm);

% axes \draw[-Latex] (-1.5\bigradius,0) -- (1.5\bigradius,0) node[below]{$\Re$} ; \draw[-Latex] (0,-0.2\bigradius) -- (0,1.4\bigradius) node[right]{$\Im$}; \end{tikzpicture}

enter image description here

Wendao
  • 15
  • Define \tikzset{my arrows/.style 2 args={postaction=decorate, decoration={markings, mark= at position #1 with {\arrow{>}}, mark= at position #2 with {\arrow{>}}} and then use my arrows = {.2}{.8} at one path and say my arrows = {.3}{.6} at another (instead of postaction = {decorate}). – Qrrbrbirlbel Apr 08 '23 at 16:20

1 Answers1

1

You could define a style which takes the position of the arrow as argument, and then use the /.list key handler in order to add multiple arrows. I used the opportunity to install arrows that bend along the paths.

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\re}{Re}
\DeclareMathOperator{\im}{Im}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,bending,calc, decorations.markings,hobby}
\begin{document}
\begin{tikzpicture}[>={Stealth[length=0.3cm,bend]},
    % stolen from https://tex.stackexchange.com/a/676562/292811
    bent arrow at/.style={decoration={markings,
        mark=at position {#1*\pgfdecoratedpathlength-0.15cm} with {\coordinate (bent arrow 1);},
        mark=at position {#1*\pgfdecoratedpathlength-0.05cm} with {\coordinate (bent arrow 2);},
        mark=at position {#1*\pgfdecoratedpathlength+0.05cm} with {\coordinate (bent arrow 3);},
        mark=at position {#1*\pgfdecoratedpathlength+0.15cm} with {\coordinate (bent arrow 4);
        \draw[-{Stealth[length=0.3cm,bend]}] (bent arrow 1) to[curve through={(bent arrow 2) .. (bent arrow 3)}]  (bent arrow 4) ;}
    }}]
    \def\bigradius{1.3}
    % contour
    \filldraw[bent arrow at/.list={.15,.4,.7},postaction = {decorate}, thick ,fill=gray!20] 
        (-\bigradius, 0) node[yshift=-8pt]{$R$}  arc (180:0:\bigradius) node[yshift=-8pt]{$-R$} --
        (\bigradius, 0) -- cycle;
    \filldraw[bent arrow at/.list={.5},postaction = {decorate}, thick, fill=white]
        (0, 0.6) circle (3.8mm);
% axes
\draw[-Latex] (-1.5*\bigradius,0) -- (1.5*\bigradius,0) node[below]{$\re z$} ;
\draw[-Latex] (0,-0.2*\bigradius) -- (0,1.4*\bigradius) node[right]{$\im z$};

\end{tikzpicture} \end{document}

enter image description here