Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 11 down vote accepted

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}
share|improve this answer
    
How to label all edges with this method? –  Wassim Sboui Jun 21 '12 at 16:48
1  
@WassimSboui: I've edited my answer to show how to use a loop with two variables. –  Jake Jun 21 '12 at 16:51

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

share|improve this answer
    
+1 but the label of the edge is wide –  Wassim Sboui Jun 21 '12 at 16:46
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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