# Drawing contour around the modular fundamental domain

I am just a beginner with TikZ and I am willing to draw in Latex the following contour, found in Serre's book :

Any help or references to draw this kind of contour efficiently (if it exists) is welcome !

• Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – Max Sep 5 '18 at 10:21

It is better, at least to put some code with some basic things in the manual to escape the situation do it for me, but as it is a trivial code that you could put at the end or a fairly competent one, my habit is to rewrite it my way since this situation allows it, that way a solution using intersections, calc, and decorations.markings, there are things to improve but there you have a code to try to understand how...

RESULT:

MWE:

\documentclass[border=20pt,tikz]{standalone}
\usetikzlibrary{intersections,calc,decorations.markings}

\begin{document}
\begin{tikzpicture}[
font=\scriptsize\bf\sffamily,
scale=2,
line width=0.75pt,
MyArrow/.style={
draw,
postaction={
decorate,
decoration={
markings,
mark=at position #1 with {
\fill(0:3pt) -- (90+50:3pt) -- (180:1pt) -- (270-50:3pt) ;
}
}
}
},
Mydashed/.style={
dash pattern =on 3pt off 2pt on 3pt off 2pt,
}
]
%Defining coodinates
\coordinate(E) at (0.5,3); \node[anchor=south west] at (E) {E};
\coordinate(A) at (-0.5,3); \node[anchor=south east] at (A) {A};
\coordinate (O) at (0,0);
\coordinate (O') at (90:1);

%Draw the X axis
\fill
(O) circle (0.7pt) node[anchor=north]{0}
(O') circle (0.7pt)
(O)edge ++(1.2,0) edge++(-1.2,0);

%Definig paths
\path[name path=hemicircle]
(0:1)node[anchor=north]{1}
arc (0:180:1)node[anchor=north]{-1};
\path[name path=CircleC]
(O') circle (3pt);
\path[name path=rectangleAE]
(A) rectangle (E |- O);
%Find firts intersections for centers of circles for B,B',D'D' points
\path[name intersections={of=hemicircle and rectangleAE}]
(intersection-1) coordinate (CenterCircleD)
(intersection-2) coordinate (CenterCircleB);
%Defining paths for circles B and D
\path[name path=CircleB]
(CenterCircleB) circle (5pt);
\path[name path=CircleD]
(CenterCircleD) circle (5pt);

%Find coordinates
\path[name intersections={of=hemicircle and CircleC}]
(intersection-1) coordinate (C')
(intersection-2) coordinate (C);
\node[anchor=north] at (C') {C'};
\node[anchor=north] at (C) {C};

\path[name intersections={of=hemicircle and CircleB}]
(intersection-1) coordinate (B')
(intersection-2) coordinate (B'2);
\node[anchor=north] at (B') {B'};
\path[name intersections={of=rectangleAE and CircleB}]
(intersection-1) coordinate (B)
(intersection-2) coordinate (B2);
\node[anchor=east] at (B) {B};

\path[name intersections={of=hemicircle and CircleD}]
(intersection-1) coordinate (D)
(intersection-2) coordinate (D2);
\node[anchor=north] at (D) {D};
\path[name intersections={of=rectangleAE and CircleD}]
(intersection-1) coordinate (D')
(intersection-2) coordinate (D'2);
\node[anchor=west] at (D') {D'};

\def\DrawArc[#1](#2)(#3)(#4)#5{%1:style 2: center 3: start 4: end 5: change direction if \n3>\n2 %Needs conditional improvement
\draw[#1]
let \p1 = ($(#3)-(#2)$), \p2 = ($(#4)-(#2)$),
\n1 = {veclen(\x1,\y1)},
\n2 = {atan2(\y1,\x1)},
\n3 = {atan2(\y2,\x2)}
in
(#2)++(\n2:\n1) arc (\n2:\n3-#5:\n1);
}

%Drawing the contour
\draw[MyArrow=0.5] (A) -- (B);
\DrawArc[MyArrow=0.5](CenterCircleB)(B)(B'){0}
\DrawArc[MyArrow=0.5](O)(B')(C){0}
\DrawArc[MyArrow=0.5](O')(C)(C'){360}
\DrawArc[MyArrow=0.5](O)(C')(D){0}
\DrawArc[MyArrow=0.5](CenterCircleD)(D)(D'){0}
\draw[MyArrow=0.5] (D') -- (E);
\draw[MyArrow=0.5] (E) -- (A);

%Drawing other details

\DrawArc[thick](O)(180:1)(CenterCircleB){0}
\DrawArc[thick](O)(CenterCircleD)(0:1){0}
\DrawArc[Mydashed](O)(CenterCircleB)(B'){0}
\DrawArc[Mydashed](O)(D)(CenterCircleD){0}

\draw[Mydashed] (B) -- (B |- O)node[anchor=north]{-1/2};
\draw[Mydashed] (D') -- (D' |- O)node[anchor=north]{1/2};

\end{tikzpicture}
\end{document}