3

I'm just starting to learn LaTex, escpecially graphics, and this is my (simplified) code:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\begin{document}
\tikzset{every loop/.style={in=30,out=160,looseness=5}}

\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto,bend angle=80] 
   \tikzstyle{place}=[circle,thick,draw=blue!75,fill=blue!20,minimum
                            size=6mm]

   \node[state,initial] (s_0)   {$s_0$};

    \path[->]
    (s_0) edge [loop above] node {x} ();

\end{tikzpicture}
\end{document}

As you can see, the loops are somewhat oval:

Current versionCurrent version incl. lines

I want the blue lines to be of equal length (second picture).

I found a very impressive solution here, but I do not need text within the arc. So my question: is there any easier trick?

ComFreek
  • 1,248
  • 2
  • 15
  • 22
  • 2
    Use out=150 (or out=180-30) if you’re using in=30? An adivce: Don’t put out and in values in the every loop style because all other loops (loop right and so on) use these directions, too. Rather change loop above directly. – Qrrbrbirlbel Oct 10 '13 at 17:31
  • @Qrrbrbirlbel Many thanks! I didn't think of such an obvious solution. I'll accept your answer if you post one. – ComFreek Oct 10 '13 at 17:34
  • @Qrrbrbirlbel Reading your advice, is there an option to set the out/in values only to every loop above combination? – ComFreek Oct 10 '13 at 17:43

1 Answers1

3

If you want symmetrical loops (to the vertical axis) you need to use “symmetrical” out and in angles, in your case either

in=30, out=180-30

or

in=40, out=160

With the style every loop you will also change loop right, loop left and loop below which will then look like loop above.

Only change the loop above style, you will either need to overwrite it:

\tikzset{
  loop above/.style={% original: above, out=105, in=75, loop
    above, in=30, out=150, loop,
    every loop/.append style={looseness=5}}}

or append the needed options as an appendix to the every loop style:

\tikzset{loop above/.append style={every loop/.append style={out=150, in=30, looseness=5}}}

This is due to how the key loop and the keys out, in and looseness work (they reset the to path to the usual curve-to path that needs a target.

Qrrbrbirlbel
  • 119,821