4

I've tried to follow this question in search for how to draw an Arrow in a nice loop from one node back to itself, but I can't figure out why my code doesn't provide me a loop. In the code below, I want the node with label A to have a loop back to itself.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{arrows,shapes,decorations,automata,backgrounds,petri}
\begin{document}

\begin{tikzpicture}

\begin{scope}[every node/.style={circle,thick,draw}]
    \node (A) at (0,3) {A};
    \node (B) at (3,3) {B};
    \node (C) at (6,3) {C};
    \node (D) at (6,0) {D};
    \node (E) at (6,-3) {E};
    \node (F) at (3,-3) {F};
    \node (G) at (0,-3) {G};
    \node (H) at (0,0) {H};
\end{scope}

\begin{scope}[>={Stealth[black]},
              every node/.style={fill=white,circle},
              every edge/.style={draw=black}]

    \path [red,->] (A.90) arc (0:264:4mm) node {$xx$} (A);
    \path [->] (A) edge node {$xx$} (B);
    \path [->] (A) edge[bend left=60] node {$xx$} (C);
    \path [->] (A) edge node {$xx$} (D);
    \path [->] (A) edge node {$xx$} (E);
    \path [->] (A) edge node {$xx$} (F);
    \path [->] (A) edge[bend right=60] node {$xx$} (G);
    \path [->] (A) edge node {$xx$} (H);

\end{scope}

\end{tikzpicture}
\end{document}

As you can see, the arrow doesn't "bend out" of the node..

enter image description here

1 Answer 1

4

\path doesn't draw any lines unless you add draw in the options, so you need \path [draw,.., or just \draw instead of \path.

You probably also want to move the node with pos, so have something like

\draw [red,->] (A.90) arc (0:264:4mm) node[pos=0.5,above left] {$xx$} (A);

enter image description here

1
  • Torbjorn, you're always answering my questions. Are you the king of Latex? :) Thank you a lot, it worked like a charm. Commented Apr 27, 2017 at 12:29

You must log in to answer this question.

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