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.

Currently I am trying to make a nice layout of logic gates for digital electronics. I have not been able to nest a tabular environment inside of a circuitikz picture, and I'm quite new at nesting in general so I haven't had much success. The only way I can make it work is if I make the table out of nodes, the equation a singular node, and the picture just stays a circuitikz picture for the corresponding logic gate.

I would like to have a systematic way of grouping the three together in some sort of horizontal array. If I had a region of space split into three sections, I could nest the equation, table, and picture all in one array. I believe this is quite complicated, but perhaps there is a trivial fix?

I have looked around but there aren't many examples involving the work I have been doing with circuitikz. Any insight is much appreciated. I have attached the following code below. I realize it is not done in the best way, but I'm VERY new to TikZ and such packages. If you mess around with it at all you will need to include the circuitikz package for successfull compilation.

\begin{figure}[H]
\centering
\begin{circuitikz}
\draw (0,0) node[nor port] {};
\draw (-2,0) node[anchor=east] {{\bf {\green NOR}}};
\draw (1.5,0) node[anchor=west] {$\mathcal{O}=\overline{{\rm A}+{\rm B}}$};
\node at (6,0.5) {${\rm A}\;\;\;\;{\rm B}\;\;\;\;\mathcal{O}$};
\draw (4.95,0.2) -- (7,0.2);
\node at (6,-0.15) {0\;\;\;\;\;0\;\;\;\;\;1};
\node at (6,-0.55) {0\;\;\;\;\;1\;\;\;\;\;0};
\node at (6,-0.95) {1\;\;\;\;\;0\;\;\;\;\;0};
\node at (6,-1.35) {1\;\;\;\;\;1\;\;\;\;\;0};

\draw (0,-3) node[nand port] {};
\draw (-2,-3) node[anchor=east] {{\bf {\green NAND}}};
\draw (1.5,-3) node[anchor=west] {$\mathcal{O}=\overline{{\rm A}\cdot{\rm B}}$};
\node at (6,-2.5) {${\rm A}\;\;\;\;{\rm B}\;\;\;\;\mathcal{O}$};
\draw (4.95,-2.8) -- (7,-2.8);
\node at (6,-3.15) {0\;\;\;\;\;0\;\;\;\;\;1};
\node at (6,-3.55) {0\;\;\;\;\;1\;\;\;\;\;1};
\node at (6,-3.95) {1\;\;\;\;\;0\;\;\;\;\;1};
\node at (6,-4.35) {1\;\;\;\;\;1\;\;\;\;\;0};

\draw (0,-6) node[xor port] {};
\draw (-2,-6) node[anchor=east] {{\bf {\green XOR}}};
\draw (0.5,-6) node[anchor=west] {$\mathcal{O}=({\rm A}+{\rm B})\cdot\overline{({\rm A}\cdot {\rm B})}$};
\node at (6,-5.5) {${\rm A}\;\;\;\;{\rm B}\;\;\;\;\mathcal{O}$};
\draw (4.95,-5.8) -- (7,-5.8);
\node at (6,-6.15) {0\;\;\;\;\;0\;\;\;\;\;0};
\node at (6,-6.55) {0\;\;\;\;\;1\;\;\;\;\;1};
\node at (6,-6.95) {1\;\;\;\;\;0\;\;\;\;\;1};
\node at (6,-7.35) {1\;\;\;\;\;1\;\;\;\;\;0};
\end{circuitikz}
\end{figure}

EDIT

alt text

share|improve this question
1  
Could you make a compilable minimal example out of your code? I cannot get your code to compile. –  Jake Jan 19 '11 at 19:28
    
@Jasper: Note that you don't have to (and shouldn't) sign with your name since it automatically appears in the lower right corner of your post. Moreover, don't forget the great invention of paragraphs! :-) –  Hendrik Vogt Jan 19 '11 at 19:56
    
@Hendrik Vogt: Habit, my apologies. Not much of a writer, but thanks. –  Jasper D'Agostino Jan 20 '11 at 0:43
    
@Jake: Each block of code is just one logic gate, it's corresponding output equation, and truth table. You can remove one of those and put it inside a circuitikz picture and see if it compiles for you. It compiles fine for me, although I don't know how to post a pdf or picture. Perhaps you dont have \usepackage{float} for the [H] option on \begin{figure} ? –  Jasper D'Agostino Jan 20 '11 at 0:45
    
@Jake: I took a screen shot from my pdf file, that's how it should look compiled. –  Jasper D'Agostino Jan 20 '11 at 0:53
show 1 more comment

1 Answer

up vote 4 down vote accepted

Usually it is structurally better to nest things the other way round; i.e. a big tabular with tikzpictures (or circutikz environments in your case) in its cells.

\begin{tabular}{cccc}
    \textcolor{green}{NOR}
    &
    \begin{circuitikz}[baseline=-0.7ex]
        \draw (0,0) node[nor port] {};
    \end{circuitikz}
    &
    $\mathcal{O} = \overline{A + B}$
    &
    $\begin{array}{ccc}
        A & B & \mathcal{O} \\ \hline
        0 & 0 & 1 \\
        0 & 1 & 0 \\
        1 & 0 & 0 \\
        1 & 1 & 0 \\
    \end{array}$
    \\
    etc.
\end{tabular}

However, sometimes one needs both the flexibility of TikZ and the structure of a table. In this case one can use the \matrix command in TikZ (see section 17 “Matrices and Alignment” of the TikZ manual (v2.10)). For nesting tabular material (like the array in this case) inside a TikZ matrix, see also Putting a tabular in a node within a matrix.

\begin{circuitikz}
    \matrix[column sep=2em, ampersand replacement=\&] {
        \node[green] {NOR};
        \&
        \node[nor port] {};
        \&
        \node {$\mathcal{O} = \overline{A + B}$};
        \&
        \node {
            $\begin{array}{ccc}
                A & B & \mathcal{O} \\ \hline
                0 & 0 & 1 \\
                0 & 1 & 0 \\
                1 & 0 & 0 \\
                1 & 1 & 0 \\
            \end{array}$
            };
        \\
        \node {etc.}; \\
    };
\end{circuitikz}
share|improve this answer
add comment

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.