18

im try to draw many edges loop above in the same node, i have writing :

\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,automata,shadows,fit,shapes}

\begin{document}

\begin{tikzpicture}[shorten >=1pt, auto,thick,initial text=,minimum size=0pt]
\node[state, accepting]            (0)                          {0};

 \path[->]      (0)  edge  [loop above]    node      {$a:\varepsilon | 1$}   ();

\end{tikzpicture} 
\end{document}

i want some thing like this (the picture is not pretty ):

enter image description here

Wassim Sboui
  • 1,831

2 Answers2

13

You can adjust the width of the loop drawn by loop above using the every loop style. With a bit of creativity you can use \foreach to draw a bunch of loops. You should wrap those paths in \begin{pgfinterruptboundingbox} to avoid the loops increasing your bounding box size too much due to their support points:

\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,automata,shadows,fit,shapes}

\begin{document}

\begin{tikzpicture}[shorten >=1pt, auto,thick,initial text=,minimum size=0pt]
\node[state, accepting]            (0)                          {0};

 \path[->]      (0)  edge  [loop above]    node      {$a:\varepsilon | 1$}   ();
\begin{pgfinterruptboundingbox}
\foreach \looseness/\label [count=\n] in {10/a,15/b,20/c,27/d,35/e}
\path [->] (0) edge [
    loop above,
    every loop/.append style={
        looseness=\looseness,
        in=60-0.8*\looseness,
        out=120+0.8*\looseness
    }] node {\label} ();
    \end{pgfinterruptboundingbox}
\end{tikzpicture} 
\end{document}
Jake
  • 232,450
8

For this purpose you should play with the min distance option from topaths library and specify manually the starting and ending angle of the arrows with in=...,out=....

In the following example, for demonstration, there are two other paths starting and ending always in the same point, but you could reproduce your image simply changing in=...,out=....

\documentclass{scrartcl}

\usepackage{tikz}
\usetikzlibrary{automata,topaths}

\begin{document}

\begin{tikzpicture}[shorten >=1pt, auto,thick,initial text=,minimum size=0pt]
\node[state, accepting] (0) {0};

\path[->](0)edge[loop above] node {$a$} ();
\path[->,min distance=3cm] (0)edge[in=78,out=102,above] node {$b$}(0);
\path[->,min distance=6cm](0)edge[in=78,out=102,above] node {$c$} (0);
\end{tikzpicture}     

\end{document}

Graphical result:

enter image description here

  • To fix with the label size, one should play with the looseness and the in/out, but @Jake answer's does it perfectly and better than I could :). – Claudio Fiandrino Jun 21 '12 at 17:00