3

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

2

\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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.