[Tex/LaTex] Drawing circuit diagrams (with logic gates) in LaTeX


I'm having some difficult drawing circuit diagrams with logic gates in LaTeX. I've tried with circuitikz and pst-circ.

\logicand[ninputs=2,invertinputa=true, invertinputb=true](0,0){Name}


Error: ! Undefined control sequence.
<recently read> \c@lor@to@ps 

l.75 ...inputa=true, invertinputb=true](0,0){Name}



\begin{circuitikz} \draw
(0,2) node[and port] (myand1) {}
(0,0) node[and port] (myand2) {}
(2,1) node[xnor port] (myxnor) {};
(myand1.out) | (myxnor.in 1)
(myand2.out) | (myxnor.in 2)

produces no error, but also no lines appear between logic gates.

Please help me generate logic diagrams from LaTeX code. (I need AND, OR, NOT, NOR and NAND gates.)

Best Answer

For the circuitikz approach: You need to tell TikZ what to do with (myand1.out), (myxnor.in 1), and so on. At the moment, you just mention the nodes, but don't tell TikZ to actually connect them, because you ended the previous \draw command already with the ;. Also, to connect nodes with straight lines, you need to use --, not |.

Here's your example in a full MWE.


\begin{circuitikz} \draw
(0,2) node[and port] (myand1) {}
(0,0) node[and port] (myand2) {}
(2,1) node[xnor port] (myxnor) {}
(myand1.out) -- (myxnor.in 1)
(myand2.out) -- (myxnor.in 2);


Related Question