[Tex/LaTex] Contour integrals

tikz-pgf

I checked this post in here Drawing complex integration but what I want is draw the one that exclude zero and negative real numbers instead of positives. I tried to play around with the code in the link above and I couldn't figure it out. I'm a beginner with the drawings in Latex

Best Answer

The quickest solution in this case is to do a reflection using xscale=-1 in the answer to the question linked:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.markings}
\begin{document}

\begin{tikzpicture}[xscale=-1]
% Configurable parameters
\def\gap{0.2}
\def\bigradius{3}
\def\littleradius{0.5}

% Axes
\draw (-1.1*\bigradius, 0) -- (1.1*\bigradius,0)
      (0, -1.1*\bigradius) -- (0, 1.1*\bigradius);
% Red path
\draw[red, thick,   decoration={ markings,
      mark=at position 0.17 with {\arrow{latex}}, 
      mark=at position 0.53 with {\arrow{latex}},
      mark=at position 0.755 with {\arrow{latex}},  
      mark=at position 0.955 with {\arrow{latex}}}, 
      postaction={decorate}]  
  let
     \n1 = {asin(\gap/2/\bigradius)},
     \n2 = {asin(\gap/2/\littleradius)}
  in (\n1:\bigradius) arc (\n1:360-\n1:\bigradius)
  -- (-\n2:\littleradius) arc (-\n2:-360+\n2:\littleradius)
  -- cycle;
\end{tikzpicture}
\end{document}

enter image description here

If you don't want to use a reflection, simply redraw the path using the appropriate points for the arcs and the straight line segments:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.markings}
\begin{document}

\begin{tikzpicture}
% Configurable parameters
\def\gap{0.2}
\def\bigradius{3}
\def\littleradius{0.5}

% Axes
\draw (-1.1*\bigradius, 0) -- (1.1*\bigradius,0)
      (0, -1.1*\bigradius) -- (0, 1.1*\bigradius);
% Red path
\draw[red, thick,   decoration={ markings,
      mark=at position 0.17 with {\arrow{latex}}, 
      mark=at position 0.53 with {\arrow{latex}},
      mark=at position 0.755 with {\arrow{latex}},  
      mark=at position 0.955 with {\arrow{latex}}}, 
      postaction={decorate}]  
  let
     \n1 = {asin(\gap/2/\bigradius)},
     \n2 = {asin(\gap/2/\littleradius)}
  in (-180-\n2:\littleradius) arc (180-\n2:-180+\n2:\littleradius) --
  (180+\n1:\bigradius) arc (-180+\n1:180-\n1:\bigradius) -- cycle;
\end{tikzpicture}
\end{document}
Related Question