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.

I am making simple Finite State Machines for a paper. My code is listed below:

%\usetikzlibrary{arrows,automata} in the preamble
\begin{tikzpicture}[>=stealth', auto,node distance=2.75cm]
  \node[state] (start)      {};
  \node[state]         (s1) [right of=start, align=left]  {isProvider\\Enabled};
  \node[state]         (s2) [right of=s1] {};
  \node[state]         (s3) [right of=s2] {};
  \path[->] (start)  edge      node {} (s1)
        (s1) edge              node[text width=1cm,align=center, pos=.4] {requestLocation\\Updates} (s2)
        (s2) edge              node[text width=1cm,align=center, pos=.3 ]{addGps\\StatusListener} (s3);
\end{tikzpicture}

I want to decrease the distance from node start to node s1 to 1cm... but only that distance between nodes. All the other edges should stay 2.75 centimeters. Any ideas or suggestions are appreciated.

share|improve this question
    
Welcome to TeX.SE! You might want to avoid right of= syntax and switch to right= of s1 syntax with positioning library. Then individual tweaks are possible with \node[state] (s1) [right = 0.5cm of start, align=left] {isProvider\\Enabled}; –  percusse Aug 12 '12 at 21:52
    
Please, always add to your questions complete minimal documents instead of just snippets. –  Gonzalo Medina Aug 12 '12 at 22:03

1 Answer 1

You can use the increased functionality of right (and similars) provided by the positioning library (see Section 16.5.3 Advanced Placement Options of the pgf manual):

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,automata}

\begin{document}
\begin{tikzpicture}[>=stealth', auto,node distance=2.75cm]
  \node[state] (start)      {};
  \node[state]         (s1) [right=1cm of start, align=left]  {isProvider\\Enabled};
  \node[state]         (s2) [right of=s1] {};
  \node[state]         (s3) [right of=s2] {};
  \path[->] (start)  edge      node {} (s1)
        (s1) edge              node[text width=1cm,align=center, pos=.4] {requestLocation\\Updates} (s2)
        (s2) edge              node[text width=1cm,align=center, pos=.3 ]{addGps\\StatusListener} (s3);
\end{tikzpicture}

\end{document}

You need to correct the placement of the labels; as they are right now the text overlaps.

share|improve this answer
    
I compiled your code above and the result is not so nice. :-) –  azetina Aug 12 '12 at 22:04
    
@azetina it is not my code; I used the OP's code, and yes it's ugly and that's why I didn't upload an image. –  Gonzalo Medina Aug 12 '12 at 22:06
    
Ugly! I would rather say inappropriate :-) –  azetina Aug 12 '12 at 22:08
    
@GonzaloMedina You are overriding the style of state which is predefined in the automata library (lack of mwe is in action here). –  percusse Aug 12 '12 at 22:10
    
@percusse Ah; since the OP didn't provide a full MWE I assumed he had forgotten the definition of state, so I provided a quick one; I'll update the answer. Thank you. –  Gonzalo Medina Aug 12 '12 at 22:18

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.