# How to make different shape nodes in automata in TikZ?

This is my code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,fit,calc,positioning,automata}

\begin{document}

\begin{tikzpicture}[shorten >=1pt,auto,node distance=7 cm, scale = 0.6, transform shape]

\node[initial,state] (A)                      {$e, n, s$};
\node[state]         (B) [right of=A]         {$w, (p+1)\%W, (p+1)\%N$};
\node[state]         (C) [below of=A]     {$(q+1)\%W, n, x$};

\end{tikzpicture}

\end{document}


This is the following output:

How can I make all of them of same size? how to draw ellipse instead such that it doesn't look that big?

-

## 1 Answer

It is possible to define a state elliptic, for example by means of:

\tikzset{elliptic state/.style={draw,ellipse}}


The ellipse requires the library shapes.geometric.

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shapes.geometric,arrows,fit,calc,positioning,automata,}

\begin{document}
\tikzset{elliptic state/.style={draw,ellipse}}
\begin{tikzpicture}[shorten >=1pt,auto,node distance=7 cm, scale = 0.6, transform shape]

\node[initial,elliptic state] (A)                      {$e, n, s$};
\node[elliptic state]         (B) [right of=A]         {$w, (p+1)\%W, (p+1)\%N$};
\node[elliptic state]         (C) [below of=A]     {$(q+1)\%W, n, x$};

\end{tikzpicture}

\end{document}


Result:

To have nodes of the same size you can specify which are the minimum width and height of the shape, but beware that ultimately this depends of the width of your text.

The example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shapes.geometric,arrows,fit,calc,positioning,automata,}

\begin{document}
\tikzset{elliptic state/.style={draw,ellipse,minimum width=6cm,minimum height=1.5cm}}
\begin{tikzpicture}[shorten >=1pt,auto,node distance=7 cm, scale = 0.6, transform shape]

\node[initial,elliptic state] (A)                      {$e, n, s$};
\node[elliptic state]         (B) [right of=A]         {$w, (p+1)\%W, (p+1)\%N$};
\node[elliptic state]         (C) [below of=A]     {$(q+1)\%W, n, x$};

\end{tikzpicture}

\end{document}


Result:

-
 Thanks a lot :). Is there some way to make all these nodes of the same size? – tikzlearner Oct 5 '12 at 10:54 Do you mean like my last update? – Claudio Fiandrino Oct 5 '12 at 11:28 Ya. Thanks again :) – tikzlearner Oct 5 '12 at 11:56