4

Current Turing Machine picture

Again I have to call on your expertise to help me draw a picture. This time it's for a Turing Machine. I have two problems with the self loops and one with the general spacing.

The first problem concerning self loops is the fact that I want to replicate this way of having multiple lines of input on one self loop:

Turing Machine multiple lines of input

I already tried using \\ and /newline but it doesn't work. Having multiple inputs on one self loop would also fix the problem of overlapping at q5.

The second problem concerning self loops is that at q2 the self loop goes straight through the connection to q6.

The problem I have with general spacing is that I would like to have q5 one space more to the right, but using right right as its position relative to q2 doesn't work.

Thank you in advance.

MWE:

\documentclass[a4paper,twoside,11pt]{article}
\usepackage{tikz, wasysym}
\usetikzlibrary{automata,positioning}

\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=4cm,on grid,auto]
   \node[state,initial] (0) {$q_0$};
   \node[state] (1) [right=of 0] {$q_1$};
   \node[state] (2) [right=of 1] {$q_2$};
   \node[state] (3) [above=of 2] {$q_3$};
   \node[state] (4) [right=of 3] {$q_4$};
   \node[state] (5) [right=of 2] {$q_5$};
   \node[state] (6) [below=of 2] {$q_6$};
   \node[state] (7) [right=of 6] {$q_7$};
   \path[->]
    (0) edge                    node {$B\:B\:R$} (1)
    (1) edge [loop above]       node {$0\:0\:R$} (1)
    (1) edge [loop below]       node {$1\:1\:R$} (1)
    (1) edge                    node {$E\:E\:L$} (2)
    (2) edge [loop below]       node {$*\:*\:L$} (2)
    (2) edge                    node {$1\:*\:R$} (3)
    (2) edge                    node {$0\:*\:R$} (6)
    (3) edge [loop above]       node {$*\:*\:R$} (3)
    (3) edge                    node {$E\:E\:R$} (4)
    (4) edge [loop above]       node {$0\:0\:R$} (4)
    (4) edge [loop right]       node {$1\:1\:R$} (4)
    (4) edge                    node {$\Box\:1\:L$} (5)
    (6) edge [loop below]       node {$*\:*\:R$} (6)
    (6) edge                    node {$E\:E\:R$} (7)
    (7) edge [loop below]       node {$0\:0\:R$} (7)
    (7) edge [loop right]       node {$1\:1\:R$} (7)
    (7) edge                    node {$\Box\:0\:L$} (5)
    (5) edge [loop right]       node {$0\:0\:L$} (5)
    (5) edge [loop right]       node {$1\:1\:L$} (5)
    (5) edge                    node {$E\:E\:L$} (2);
\end{tikzpicture}

\end{document}
Carst
  • 95
  • 4
  • How is the first image related to your question? 2) That you use TexMaker is not relevant 3) Is that question, regarding line break in tikz nodes, helpful? It basically amount to write node[text width=1cm]{$\Box\:0\:L$\\$\Box\:1\:R$} to get two lines in the same node.
  • – Clément Nov 20 '15 at 21:49
  • The first image is my current output. I refer to the image in the text.

    I tried using "\" to get multiple lines of input on one loop but that didn't work.

    – Carst Nov 20 '15 at 21:51
  • 1
    Add [text width=1cm] as a parameter of your node. – Clément Nov 20 '15 at 21:52