# [Tex/LaTex] Moving edge labels in TikZ using draw edge

tikz-pgftikz-styles

I just started using LaTeX and TikZ, and I am having trouble figuring out how to move a label above an edge. I have included my code and the resulting picture below. I would like to move the "5" labels above their corresponding edge so that there is less ambiguity. I tried the option above (as well as others) in the brackets following the "5" but the label stayed on the same side of the edge. Thanks in advance!

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows, quotes}
\begin{document}

\begin{tikzpicture}[auto, node distance = 5cm]

\node (1) {A};
\node (2) [below left of=1] {B};
\node (3) [below right of=2] {C};
\node (4) [below right of=1] {D};

\tikzset{edge/.style = {line width = 1.0, ->}}

\draw[edge] [loop above] (1) to ["1"] (1);
\draw[edge] (1) to ["5"] (2);
\draw[edge] [bend right] (1) to ["2"] (3);
\draw[edge] [bend left] (1) to ["-4"] (4);

\draw[edge] [bend left] (2) to ["3"] (1);
\draw[edge] [loop left] (2) to ["4"] (2);
\draw[edge] (2) to ["5"] (3);
\draw[edge] [bend right] (2) to ["7"] (4);

\draw[edge] [bend right] (3) to ["8"] (1);
\draw[edge] [bend left] (3) to ["9"] (2);
\draw[edge] [loop below] (3) to ["6"] (3);
\draw[edge] (3) to ["5"] (4);

\draw[edge] (4) to ["5"] (1);
\draw[edge] [bend right] (4) to ["10"] (2);
\draw[edge] [bend left] (4) to ["11"] (3);
\draw[edge] [loop right] (4) to ["12"] (4);

\end{tikzpicture}
\end{document}


If you follow the quoted label with a single quotation mark, it will 'flip' to the other side of the line e.g. right to left or above to below.

I've updated your code to specify the arrows.meta library and the positioning library's syntax. I've also changed edge to my edge. edge is extremely confusing since it is already widely used by TikZ. At least, it certainly confused me. Then again, perhaps I'm just easily confused.

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,quotes,positioning}
\begin{document}
\begin{tikzpicture}[auto, node distance = 5cm]

\node (1) {A};
\node (2) [below left=of 1] {B};
\node (3) [below right=of 2] {C};
\node (4) [below right=of 1] {D};

\tikzset{my edge/.style = {line width = 1.0, ->}}

\draw[my edge] [loop above] (1) to ["1"] (1);
\draw[my edge] (1) to ["5"'] (2);
\draw[my edge] [bend right] (1) to ["2"] (3);
\draw[my edge] [bend left] (1) to ["-4"] (4);

\draw[my edge] [bend left] (2) to ["3"] (1);
\draw[my edge] [loop left] (2) to ["4"] (2);
\draw[my edge] (2) to ["5"'] (3);
\draw[my edge] [bend right] (2) to ["7"] (4);

\draw[my edge] [bend right] (3)  to ["8"] (1);
\draw[my edge] [bend left] (3) to ["9"] (2);
\draw[my edge] [loop below] (3) to ["6"] (3);
\draw[my edge] (3) to ["5"'] (4);

\draw[my edge] (4) to ["5"'] (1);
\draw[my edge] [bend right] (4) to ["10"] (2);
\draw[my edge] [bend left] (4) to ["11"] (3);
\draw[my edge] [loop right] (4) to ["12"] (4);

\end{tikzpicture}
\end{document}


Flipping fives: