8

I want a diagram to demonstrate the dogbone contour like: enter image description here

I have found some useful pages to teach myself, such as

TikZ: complicated paths, e.g. for complex integrals

Drawing complex integration

I tried to modify some parameters in above cases, however, after two days's struggle, I failed to realize it.

Any help is appreciated.


supplement

enter image description here

3 Answers 3

6

Standard tikz paths (--s, circles, and arcs) can be used here along with the decorations.markings library to add the arrow tips on paths. To efficiently decorate the paths without repeating the same definitions, a dec/.style is defined as:

dec/.style args={#1#2}{
    decoration={%
        markings,
        mark=at position #1 with {#2}
    },
    postaction={decorate}
}

In this case, only the arrow position and its shape are inserted as arguments #1 and #2. Here is how the full code looks like:

\documentclass[border=2pt,tikz]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\small

\begin{tikzpicture}[
    scale=2,
    line cap=round,
    dec/.style args={#1#2}{
        decoration={markings, mark=at position #1 with {#2}},
        postaction={decorate}
    }
]
\path [gray,thin] (-1.2,0) edge[->] (1.2,0)  (0,-1.2) edge[->] (0,1.2);
\draw [blue, dec={0.29}{\arrow{>}}] (0,0) circle (1cm); 

\draw [red, xshift=.5cm, dec={0.29}{\arrow{<}}]
    (-160:1mm)coordinate(21) arc (-160:160:1mm) coordinate(11); 
\draw [red, xshift=-.5cm, dec={0.29}{\arrow{<}}]
    (20:1mm)coordinate(12)   arc (20:340:1mm) coordinate(22);    
\draw [red] (11)--(12) (21)--(22);

\path (.29*360:1.15cm) node {$C$}
    (0,2mm)[anchor=east] node {$M\rightarrow$}
    (0,-2mm)[anchor=west] node {$\leftarrow N$}
    (-8mm,2mm) node {$\gamma_1$}
    (5mm,2mm) node {$\gamma_2$};
\end{tikzpicture}

\end{document}

enter image description here

The second picture can be coded like this:

\scriptsize
\begin{tikzpicture}[
    scale=2,
    line cap=round,
    dec/.style args={#1#2}{
        decoration={markings, mark=at position #1 with {#2}},
        postaction={decorate}
    }
]
\path[gray,very thin,xshift=-1.2cm] (-.2,0) edge[->] (2.4,0)  (0,-1.2) edge[->] (0,1.2);
\draw[red,dec={0.59}{\arrow{>}}]  
    ({-180+asin(0.1)}:1cm)coordinate(1) arc ({-180+asin(0.1)}:{180-asin(0.1)}:1cm)coordinate(3); 
\draw[red][dec={0.59}{\arrow{<}}] 
    ({-180+asin(.5)}:2mm)coordinate(2)  arc ({-180+asin(.5)}:{180-asin(.5)}:2mm)coordinate(4);    

\draw[red, dec={0.69}{\arrow{<}}] (1)--node[below,black]{$\leftarrow N$}(2);
\draw[red, dec={0.39}{\arrow{>}}] (3)--node[above,black]{$M\rightarrow$}(4);

\path (60:3mm) node{$\gamma_r$} 
    (40:1.12cm) node{$\gamma_R$} 
    (0,0)node[circle,fill=gray,inner sep=.5pt]{};    
\end{tikzpicture}

enter image description here

3
  • It's really helpful! Thank you so much. It seem it's useful to learn how to manipulate those codes: dec/.style args ... I searched it in the manual of tikz, no key word is found. Any study advice from you?
    – Zoe Rowa
    Commented Mar 14, 2016 at 2:24
  • Dear AboAmmar, I would like to understand your code well, could you draw the digram in supplement (I added it for this teaching.) ? Please produce it in the style of your code above, comparing the two cases, I might grasp better how to deal with those problems. Many Thanks.
    – Zoe Rowa
    Commented Mar 14, 2016 at 7:59
  • +1, nice, I liked how you coded the "cut-out" circles. Just one question: is there a reason for using edges for the axis instead of plain --?
    – Rmano
    Commented Mar 14, 2016 at 8:22
3

Here is a starting point in luamplib + Metapost which you might find useful. I hope the syntax is fairly clear, but the detailed manual and several good introductions are available at the second link above. To use luamplib you must use lualatex as the TeX engine.

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
% axes
path xx, yy;
xx = (left--right) scaled 89;
yy = xx rotated 90;
drawarrow xx withcolor .7 white;    
drawarrow yy withcolor .7 white;    

% circle C rotated so the arrow head is in the right place 
path C;
C = fullcircle scaled 144 rotated 120;
drawarrow C withcolor .53 blue;
label.ulft("$C$", point 0 of C);

% the two poles
pair gamma[];
-gamma1 = gamma2 = 34 right;

% parts of the bone
path bone[], g[]; 
g1 = fullcircle scaled 18 shifted gamma1;
g2 = fullcircle scaled 18 shifted gamma2;
r = 0.6;
bone1 = subpath (2,r) of g1 -- subpath (4-r,-2.2) of g2;
bone2 = bone1 rotated 180;

drawarrow bone1 withcolor .67 red;
drawarrow bone2 withcolor .67 red;

begingroup;
interim labeloffset := 10;
dotlabel.ulft("$\gamma_1$", gamma1);
dotlabel.urt ("$\gamma_2$", gamma2);
endgroup;

% arrow markers
path a[];
a1 = (left--right) scaled 8 shifted 13 up;
a2 = a1 rotated 180;
drawarrow a1;
drawarrow a2;
label.lft("$M$", point 0 of a1);
label.rt ("$N$", point 0 of a2);

endfig;
\end{mplibcode}
\end{document}
2
  • Thank you for the clear explanation. luamplib + Metapost seem the counterpart of tikz in lualatex.
    – Zoe Rowa
    Commented Mar 14, 2016 at 2:02
  • @ZoeRowa You can of course use TikZ with LuaLaTeX as well. Commented Mar 14, 2016 at 9:39
1

With tkz-euclide

\documentclass[a4paper]{article}
\usepackage{amsmath,tkz-euclide}
\usetkzobj{all} 
\begin{document}    
\begin{tikzpicture} 
    \xdef\Rad{4}
   \tkzInit 
   \tkzDefPoint(0,0){O}  \tkzDefPoint(-2,0){I} \tkzDefPoint(2,0){J} 
   \begin{scope}[decoration={markings, mark=at position 0.33 with {\arrow{>}}}]
       \tkzDrawCircle[R,postaction={decorate},very thick](O,\Rad cm)
   \end{scope}
   \begin{scope}[decoration={markings, mark=at position 0.33 with {\arrow{<}}}]
       \tkzDrawArc[R,very thick,postaction={decorate}](I,4mm)(30,330)
       \tkzDrawArc[R,very thick,postaction={decorate}](J,4mm)(210,150)
   \end{scope}
     \tkzDefPoint({2-cos(3.14/180*30)*0.4},{sin(3.14/180*30)*0.4}){ja}
     \tkzDefPoint({cos(3.14/180*30)*0.4-2},{sin(3.14/180*30)*0.4}){ia}
     \tkzDefPoint({2-cos(3.14/180*30)*0.4},{-sin(3.14/180*30)*0.4}){jb}
     \tkzDefPoint({cos(3.14/180*30)*0.4-2},{-sin(3.14/180*30)*0.4}){ib}
     \tkzDrawSegments[very thick](ja,ia jb,ib)

     \tkzLabelCircle[R,above left](O,\Rad)(120){$\mathcal{C}$}
     \tkzLabelPoint[above left=10pt](I){$\mathcal{\gamma}1$}
     \tkzLabelPoint[below right=10pt](J){$\mathcal{\gamma}2$}
     \tkzDrawPoints(I,J)

     \tkzDefPoint(-0.5,0.75){ma}  \tkzDefPoint(0.5,0.75){na}
     \tkzDrawSegment[->](ma,na) \tkzLabelPoint[left](ma){M}
\end{tikzpicture}
\end{document}

enter image description here

Code for the second figure

\documentclass[a4paper]{article}
\usepackage{amsmath,tkz-euclide}
\usetkzobj{all} 
\begin{document}    
\begin{tikzpicture} 
   \tkzInit 
   \tkzDefPoint(0,0){O}  
  \tkzDefPoint(-4,0.2){I1} \tkzDefPoint(4,0.2){J1} 
   \tkzDefPoint(-4,-0.2){I2} \tkzDefPoint(4,-0.2){J2} 
    \begin{scope}[decoration={markings, mark=at position 0.33 with {\arrow{>}}}]
      \tkzInterLC[R](I1,J1)(O,4 cm) \tkzGetFirstPoint{m}  
      \tkzInterLC[R](I2,J2)(O,4 cm)  \tkzGetSecondPoint{q}
      \tkzInterLC[R](I1,J1)(O,4 mm) \tkzGetFirstPoint{n}  
      \tkzInterLC[R](I2,J2)(O,4 mm) \tkzGetSecondPoint{p}  
      \tkzDrawSegment[-](m,n)  \tkzDrawSegment[-](p,q)
      \tkzDrawArc[R with nodes,postaction={decorate},very thick](O,4 cm)(q,m)
      \tkzDrawArc[R with nodes,postaction={decorate},very thick](O,4 mm)(p,n)
    \end{scope}  
\end{tikzpicture}
\end{document}

enter image description here

1
  • Thank you for your help. I can manipulate your code to decorate the digram.
    – Zoe Rowa
    Commented Mar 14, 2016 at 2:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .