2

I want to draw a transducer (automaton) that has the following characteristic. In every final state some edges leave those states with a letter label and don't go to any node. But i want to be able to define the angle of the edges. How can i do that?

\documentclass[12pt, a4paper, oneside, openany]{memoir}
\usepackage{fontspec}
\usepackage{xgreek}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\setmainfont{Times New Roman}

%automata package
\usepackage{tikz}
\usetikzlibrary{automata, positioning}

\begin{document}
    \begin{tikzpicture}[shorten >= 1pt, node distance = 3cm, on grid, auto]
    \node [state, initial] (0) {0};
    \node [state] (1) [above right=of 0] {1};
    \node [state] (2) [below right=of 0] {2};
    \node [state, accepting] (3) [above right= of 2] {3};

    \path[->]
        (0) edge                                  node           {a:a}           (1)
 edge[bend right]               node[swap]{b:a}     (2)
        (1) edge                                  node{a:a}                (3)
        (2)  edge[bend right]               node{b:a}               (3)
        (3) edge node [above] {a} +(2,0);

    \end{tikzpicture}

\end{document}

Sorry for the bad alignment...So i have a state (3) which is an accepting one and I want two edges strart from three going nowhere. But i want them to be with different angles like one going upwards and one going downwards. I have managed to add one edge that goes nowhere

(3) edge node [above] {a} +(2,0);

but can get it to change the angle. And a second not so relevant and please excuse me for that. Can i add a caption on my automaton like

Figure 1
Example of transducer

1 Answer 1

2

just change y coordinates:

    (3) edge node [right] {a} +(0,2)
    (3) edge node [right] {a} +(0,-2);

Code:

\documentclass[12pt, a4paper, oneside, openany]{memoir}
%\usepackage{fontspec}
%\usepackage{xgreek}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
%\setmainfont{Times New Roman}

%automata package
\usepackage{tikz}
\usetikzlibrary{automata, positioning}

\begin{document}
\chapter{one}
\begin{figure}[htb]
  \centering
    \begin{tikzpicture}[shorten >= 1pt, node distance = 3cm, on grid, auto]
    \node [state, initial] (0) {0};
    \node [state] (1) [above right=of 0] {1};
    \node [state] (2) [below right=of 0] {2};
    \node [state, accepting] (3) [above right= of 2] {3};

    \path[->]
        (0) edge                                  node           {a:a}           (1)
 edge[bend right]               node[swap]{b:a}     (2)
        (1) edge                                 node{a:a}                (3)
        (2)  edge[bend right]               node{b:a}               (3)
        (3) edge node [above] {a} +(2,+1) 
        (3) edge node [below] {b} +(2,-1);

    \end{tikzpicture}
    \caption[my figure]{Example of transducer}\label{fig:transducer}
\end{figure}
\end{document}

enter image description here

To get the caption, just enclose tikzpicture inside figure environment.

4
  • Thank you for answering....It was my mistake but what i ment was not vertically upwards and downwards but diagonaly :)....I guess i still have to play with x and y?How can i achieve it?
    – Apostolos
    Commented Oct 1, 2013 at 13:37
  • @Apostolos They are diagonally up and down. Sorry I could not follow.
    – user11232
    Commented Oct 1, 2013 at 13:49
  • Got it thank you. The last edges were produced like this: (3) edge node [above] {a} +(2,+1) (3) edge node [above] {b} +(2,-1); In your figure they seem to be verticaly upwards and downwards and not dianogaly. But thank you for leading me to the right direction :)
    – Apostolos
    Commented Oct 1, 2013 at 13:50
  • @Apostolos Glad that it helped. I have updated the answer just for record. :)
    – user11232
    Commented Oct 1, 2013 at 13:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .