# Automat within Record

I'd like to define a new shape with parameters (input/ouput variables and a automat).

It should look like:

INPUT                                          OUTPUT
+------+--------------------------------------+------+
|      |                                      |      |
|  v1  |                                      |      |
|      |                                      |      |
+------+             AUTOMAT                  |  o1  |
|      |                                      |      |
|  v2  |                                      |      |
|      |                                      |      |
+------+--------------------------------------+------+


I'm not skilled enought to define such a complex object. I appreciate any help.

-
Welcome to TeX.sx! Instead of posting a “Thank you” as an additional answer, you should thank Claudio by upvoting his answer (with the upward pointing arrow to the left of it) and accepting it (by clicking on the checkmark). –  diabonas Jul 24 '12 at 9:46
@drh In order to accept or upvote answers (and contribute to the community with questions and, possibly, answers) you should register. –  egreg Jul 24 '12 at 11:07

Do you mean something like this?

The picture has been realized by means of:

\documentclass{article}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}

\newcounter{image}
\setcounter{image}{0}
\pgfmathtruncatemacro{\recordwidth}{4}
\pgfmathtruncatemacro{\recordheight}{2}

\newcommand{\setrecordwidth}[1]{\pgfmathtruncatemacro{\recordwidth}{#1}}
\newcommand{\setrecordheight}[1]{\pgfmathtruncatemacro{\recordheight}{#1}}

\tikzset{drawinside/.code n args={4}{%
\node at ($(#1.north west)!0.5!(#1.west)!0.15!(#1.center)$){#2};
\node at ($(#1.south west)!0.5!(#1.west)!0.15!(#1.center)$){#3};
\draw($(#1.north west)!0.30!(#1.north)$)--($(#1.south west)!0.30!(#1.south)$);
\draw(#1.west)--($(#1.west)!0.30!(#1.center)$);
\draw($(#1.north east)!0.30!(#1.north)$)--($(#1.south east)!0.30!(#1.south)$);
\node at ($(#1.east)!0.15!(#1.center)$) {#4};
}
}

\tikzset{record/.style args={#1 and #2}{
rectangle,draw,minimum width=#1, minimum height=#2
}
}

\NewDocumentCommand{\drawrecord}{d() m m m}{
\stepcounter{image}
\IfNoValueTF{#1}{%true
\node[record=\recordwidth cm and \recordheight cm,name=a\theimage]{};
}
{%false
\node[record=\recordwidth cm and \recordheight cm,name=a\theimage]at(#1){};
}
\node[drawinside={a\theimage}{#2}{#3}{#4}]{};
}

\begin{document}
\tikz{\drawrecord{$v_1$}{$v_2$}{$o_1$}}
\tikz{\drawrecord{$v_4$}{$v_5$}{$o_2$}}

\vspace*{2cm}
\begin{tikzpicture}
\drawrecord(0,0){$v_1$}{$v_2$}{$o_1$}
\setrecordwidth{6}
\setrecordheight{3}
\drawrecord(7,0){$v_1$}{$v_2$}{$o_1$}
\end{tikzpicture}
\end{document}


The basic command is \drawrecord that accepts as parameters the input and output variables and as an optional parameter, the position of the picture. It is possible to customize the width and the height of the record through the dedicated commands \setrecordwidth and \setrecordheight.

-
That's a first trial, since I don't know how to handle the automat. Is it simply a label to be inserted in the middle? –  Claudio Fiandrino Jul 21 '12 at 14:57