# How to draw loop arrow and right left arrow

I attempt to draw my map and I'm stuck in drawing the following \

• drawing a loop above from 1 to 1
• drawing loop down from -1 to -1
• drawing bend above arrow from 2 and ending in 3 and bend down arrow from 3 and ending in 2
• drawing bend above arrow from -2 and ending in -3 and bend down arrow from -3 and ending in -2
• I also drew an "arrow" from 3 to -4 and another one from 4 to -3 but how to make them appear as a double-headed arrow connecting them. Sorry, I'm still a leTEX learner and I attempted a lot with no luck! This is my attempt and could you please help me and look at my handed drwawing picture as well.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage[english]{babel}
\usepackage{pgf,tikz} % for a sample picture that is included below
\usetikzlibrary{arrows}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}

\tikzset{graph-1/.style = {
line cap = round,
line join = round,
> = triangle 45,
x=0.37cm, y=0.37cm,
every node/.append style = {inner ysep=2mm}
}
}% end of tikzset

\begin{figure}[ht]
\centering
\begin{tikzpicture}[graph-1]

\foreach \x in {0, 2, 4}
\foreach \x/\label in {0/\scriptstyle1, 2/\scriptstyle2, 4/\scriptstyle3, 6/\scriptstyle4, 8/\scriptstyle5}
\draw[fill=uuuuuu]  (\x,1.5) circle (1.3pt) node[above] {$\label$};
%
\foreach \x/\label in {0/\scriptstyle-1, 2/\scriptstyle -2, 4/\scriptstyle-3, 6/\scriptstyle-4, 8/\scriptstyle-5}
\draw[fill=uuuuuu]  (\x,-1.5) circle (1.3pt) node[below] {$\label$};
\foreach \x in {4}
\draw  (\x,1.5) -- (\x+2,-1.5);
\foreach \x in {6}
\draw  (\x,1.5) -- (\x-2,-1.5);
%
%\foreach \x in {0}  [it does not work to draw a loop]
%\draw [uuuuuu,->,gray, loop above] (\x) edge (\x)
%\draw [uuuuuu] (\x) --  (\x)
%\draw (\x) -- (\x)
%
\node[left] at (-.3,0) {$\pi=$};
\end{tikzpicture}
\end{figure}
\end{document}

• Why my laTEX commands didn't display properly in my question? Commented Feb 13, 2018 at 5:49
• To format code blocks you need to indent them 4 spaces, or select them and use the {} symbol in the gui. Also, it's easier to help you if you post a minimal working example. In particular, please remove all unnecessary packages...
– user30471
Commented Feb 13, 2018 at 5:55
• got it. Sure I will. thanks a lot Andrew and also thanks Habicht Commented Feb 13, 2018 at 5:56
• May I ask you to clean your code up, i.e. to remove all the style files and macros that are not essential to the problem? BTW, the commended out \draw commands lack ; in the end.
– user121799
Commented Feb 13, 2018 at 6:02

Possible solution:

You should use the proper TikZ commands if you want to create nodes with labels, that is: nodes with labels. Then you can easily draw arrows from one node to the other. Also, it does not make that much sense to use a foreach loop only for one single command.

I amended your code. The two foreach loops create the nodes and give them the names t0, t2, t4, t6, t8 and b0, b2 etc.

You may want to draw the arrows differently.

\documentclass[12pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{backgrounds}
\usetikzlibrary{arrows}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}

\tikzset{graph-1/.style = {
> = triangle 45,
x=0.37cm, y=0.37cm }
}% end of tikzset

\begin{figure}[ht]
\centering
\begin{tikzpicture}[graph-1]

\foreach \x/\label in {0/\scriptstyle1, 2/\scriptstyle2, 4/\scriptstyle3, 6/\scriptstyle4, 8/\scriptstyle5}
\node[fill=uuuuuu,inner sep=1.3pt,circle,label=above:{$\label$}] at (\x,1.5) (t\x) {};

\foreach \x/\label in {0/\scriptstyle-1, 2/\scriptstyle -2, 4/\scriptstyle-3, 6/\scriptstyle-4, 8/\scriptstyle-5}
\node[fill=uuuuuu,inner sep=1.3pt,circle,label=below:{$\label$}] at (\x,-1.5) (b\x) {};

\draw[<->] (t6) -- (b8);
\draw[<->] (t8) -- (b6);

\draw[uuuuuu,->] (t0) to[loop below] (t0);
\draw[uuuuuu,->] (b0) to[loop above] (b0);

\draw[uuuuuu,->] (t2) to[bend right] (t4);
\draw[uuuuuu,->] (t4) to[bend right] (t2);
\draw[uuuuuu,->] (b2) to[bend left] (b4);
\draw[uuuuuu,->] (b4) to[bend left] (b2);

\node[left] at (-.3,0) {$\pi=$};
\end{tikzpicture}
\hfil

\end{figure}

\end{document}


Edit: With smaller arrow heads and the loops to the other side.

\documentclass[12pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{backgrounds}
\usetikzlibrary{arrows}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}

\tikzset{graph-1/.style = {
>=stealth,
x=0.37cm, y=0.37cm }
}% end of tikzset

\begin{figure}[ht]
\centering
\begin{tikzpicture}[graph-1]

\foreach \x/\label in {0/\scriptstyle1, 2/\scriptstyle2, 4/\scriptstyle3, 6/\scriptstyle4, 8/\scriptstyle5}
\node[fill=uuuuuu,inner sep=1.3pt,circle,label=above:{$\label$}] at (\x,1.5) (t\x) {};

\foreach \x/\label in {0/\scriptstyle-1, 2/\scriptstyle -2, 4/\scriptstyle-3, 6/\scriptstyle-4, 8/\scriptstyle-5}
\node[fill=uuuuuu,inner sep=1.3pt,circle,label=below:{$\label$}] at (\x,-1.5) (b\x) {};

\draw[<->] (t6) -- (b8);
\draw[<->] (t8) -- (b6);

\draw[uuuuuu,->] (t0) to[out=135,in=45,looseness=30] (t0);
\draw[uuuuuu,->] (b0) to[out=-135,in=-45,looseness=30] (b0);

\draw[uuuuuu,->] (t4) to[bend left] (t2);
\draw[uuuuuu,->] (t2) to[bend left] (t4);
\draw[uuuuuu,->] (b2) to[bend left] (b4);
\draw[uuuuuu,->] (b4) to[bend left] (b2);

\node[left] at (-.3,0) {$\pi=$};
\end{tikzpicture}
\hfil

\end{figure}

\end{document}


• Thanks Habicht! You are kind and supportive. Yes, I wish if it's similar to the photo I uploaded Commented Feb 13, 2018 at 6:26
• Hi Habicht, is there a way to make the head of an arrow small not big. Thanks again Commented Feb 13, 2018 at 6:36
• Thank you so much Habicht! You are really helpful and I'm now so happy that this map was drawn Commented Feb 13, 2018 at 6:42

slightly modified nice answer of Jasper Habicht (I could not resist to make it more concise :-( ):

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}

\tikzset{graph-1/.style = {
>={Stealth[length=1.5mm]},
x=0.37cm, y=0.37cm,
every label/.append style = {font=\scriptsize},
dot/.style = {circle, fill=uuuuuu, inner sep=1.3pt}
}
}% end of tikzset

\begin{figure}[ht]
\centering
\begin{tikzpicture}[graph-1]

\foreach \x/\label in {0/1, 2/2, 4/3, 6/4, 8/5}
{
\node[dot,label=$\label$ ] at (\x, 1.5) (t\x) {};
\node[dot,label=below:$-\label$] at (\x,-1.5) (b\x) {};
}
\node[left=3mm] at (0,0) {$\pi=$};

\draw[uuuuuu,->]
(t0) edge[out= 135,in= 45,looseness=30] (t0)
(b0) edge[out=-135,in=-45,looseness=30] (b0)

(t4) edge[bend left] (t2)
(t2) edge[bend left] (t4)
(b2) edge[bend left] (b4)
(b4) edge[bend left] (b2);
\draw[uuuuuu,<->]  (t6) edge (b8)
(t8) edge (b6);
\end{tikzpicture}
\end{figure}

\end{document}


the result is almost the same (tiny differences can be in arrows heads size):