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'm building a figure of a finite state automate. However the edge of F to C seems to make the image less readable. Using bend options doesn't solve the problem. is there a way to solve this problem? Introducing a phantom node could be a solution I think, but I don't know any option that generates an edge through that phantom node.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,automata}
\begin{document}
\begin{tikzpicture}[->,shorten >=1pt,auto,node distance=2cm,on grid,semithick,state/.style=state with output,every state/.style={draw=black!50,very thick,fill=black!20,scale=0.75}]
\node[state] (E) {$e$\nodepart{lower} $1$};
\node[state] (F) [right=of E] {$f$\nodepart{lower} $1$};
\node[state] (A) [below=of E] {$a$\nodepart{lower} $0$};
\node[state] (B) [below=of F] {$b$\nodepart{lower} $0$};
\node[state] (C) [below=of A] {$c$\nodepart{lower} $0$};
\node[state] (D) [below=of B] {$d$\nodepart{lower} $0$};
\path (A) edge[loop left] node {00} (A)
      edge[bend left] node {01} (B)
      edge[bend left] node {10} (C)
      (B) edge[bend left] node {00} (A)
      edge[loop right] node {01} (B)
      edge node {11} (F)
      (C) edge[bend left] node {00} (A)
      edge[loop left] node {10} (C)
      edge[bend left] node {11} (D)
      (D) edge node {00} (B)
      edge[bend left] node {10} (C)
      edge[loop right] node {11} (D)
      (E) edge node {00} (A)
      edge[loop left] node {01} (E)
      edge[bend left] node {11} (F)
      (F) edge[bend left] node {01} (E)
      edge[loop right] node {11} (F)
      edge node {10} (C);
\end{tikzpicture}
\end{document}
share|improve this question
2  
Does this : \draw (F) .. controls ([shift={(4cm,-4cm)}] F) and ([shift={(2cm,-3cm)}] C).. (C) ; work for you? –  percusse Mar 12 '12 at 19:28
    
basically this is a good solution. I only think Tikz handles the command badly because the bounds of the image is set to the control points of the Bezier-curve. This makes the image perhaps too large. –  CommuSoft Mar 13 '12 at 1:09
    
Have a look at this –  percusse Mar 13 '12 at 2:04
    
Many thanks! That indeed solves the problem! –  CommuSoft Mar 13 '12 at 2:18
1  
add node [midway] {10} just before the semicolon. –  percusse Mar 14 '12 at 0:55
show 1 more comment

2 Answers

up vote 5 down vote accepted

It's like the answer of rpapa but you don't need to use fit library. The solution works with the current bounding box. We know that the bounding box is update when a path is added. So we can use the last bounding box and more precisely the last south east corner.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,automata}
\begin{document}
\begin{tikzpicture}[->,
                    shorten >=1pt,
                    auto,
                    node distance=2cm,
                    on grid,
                    semithick,state/.style=state with output,
                    every state/.style={draw=black!50,
                                        very thick,
                                        fill=black!20,
                                        scale=0.75}]
\node[state] (E) {$e$\nodepart{lower} $1$};
\node[state] (F) [right=of E] {$f$\nodepart{lower} $1$};
\node[state] (A) [below=of E] {$a$\nodepart{lower} $0$};
\node[state] (B) [below=of F] {$b$\nodepart{lower} $0$};
\node[state] (C) [below=of A] {$c$\nodepart{lower} $0$};
\node[state] (D) [below=of B] {$d$\nodepart{lower} $0$};
\path (A) edge[loop left] node {00} (A)
      edge[bend left] node {01} (B)
      edge[bend left] node {10} (C)
      (B) edge[bend left] node {00} (A)
      edge[loop right] node {01} (B)
      edge node {11} (F)
      (C) edge[bend left] node {00} (A)
      edge[loop left] node {10} (C)
      edge[bend left] node {11} (D)
      (D) edge node {00} (B)
      edge[bend left] node {10} (C)
      edge[loop right] node {11} (D)
      (E) edge node {00} (A)
      edge[loop left] node {01} (E)
      edge[bend left] node {11} (F)
      (F) edge[bend left] node {01} (E)
      edge[loop right] node {11} (F); 
 \draw (F) 
           to [out=45,in=45] (current bounding box.south east) 
           to [out=-135,in=-60] node[below,midway]{11} (C);   

\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
je pense pas assez souvent à bounding box –  rpapa Mar 14 '12 at 19:47
add comment

you can fit the node and use south east corner to draw the path with

\draw (F) to [out=45,in=45] (box.south east) to[out=-135,in=-45]  (C);  

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,automata,fit}
\begin{document}
\begin{tikzpicture}[->,shorten >=1pt,auto,node distance=2cm,on grid,semithick,state/.style=state with output,every state/.style={draw=black!50,very thick,fill=black!20,scale=0.75}]
\node[state] (E) {$e$\nodepart{lower} $1$};
\node[state] (F) [right=of E] {$f$\nodepart{lower} $1$};
\node[state] (A) [below=of E] {$a$\nodepart{lower} $0$};
\node[state] (B) [below=of F] {$b$\nodepart{lower} $0$};
\node[state] (C) [below=of A] {$c$\nodepart{lower} $0$};
\node[state] (D) [below=of B] {$d$\nodepart{lower} $0$};



\path (A) edge[loop left] node {00} (A)
      edge[bend left] node {01} (B)
      edge[bend left] node {10} (C)
      (B) edge[bend left] node {00} (A)
      edge[loop right] node {01} (B)
      edge node {11} (F)
      (C) edge[bend left] node {00} (A)
      edge[loop left] node {10} (C)
      edge[bend left] node {11} (D)
      (D) edge node {00} (B)
      edge[bend left] node[name=bas] {10} (C)
      edge[loop right] node[name=basdroit] {11} (D)
      (E) edge node {00} (A)
      edge[loop left] node {01} (E)
      edge[bend left] node {11} (F)
      (F) edge[bend left] node {01} (E)
      edge[loop right] node {11} (F);

\node[draw=red, fit=(E) (C) (F) (basdroit) (bas) ](box) {};  

  \draw (F) to [out=45,in=45] (box.south east) to[out=-135,in=-45] node[below,midway]{11} (C);   

\end{tikzpicture}
\end{document}

fit node and path

share|improve this answer
add comment

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.