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.

Could somebody help me, please?

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.

share|improve this question
1  
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
1  
@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

1 Answer 1

Do you mean something like this?

enter image description here

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.

share|improve this answer
    
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

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.