2

So I'm trying to draw the following circuit (Which looks like a half adder) using circuitikz.

correct non-overlapping inputs

However, my code is producing the below diagram.

Overlapping inputs to second logic gate

\begin{circuitikz}
\draw (0, 4)node[xor port] (xorone){}
(0, 2)node[and port] (and){}
(xorone.in 1) node[left=0.5cm](a) {A}
(xorone.in 2) node[left=0.5cm](b) {B}

(a) -| (xorone.in 1)
(b) -| (xorone.in 2)
(a) -| (and.in 1)
(b) -| (and.in 2);  
\end{circuitikz}

Is there any way I can make the two wires connecting the gates in 'parallel' not overlap?

4

Usually one adds branch points where wires connect, either with to[short,o-*] or node[circ] and node[ocirc]. I specified point (branch) midway between (b.east) and (xorone.in 2).

Note: circuitikz always loads the calc library.

\documentclass[border=1pt]{standalone}
\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}
\draw (0, 4)node[xor port] (xorone){}
(0, 2)node[and port] (and){}
(xorone.in 1) node[left=0.5cm](a) {A}
(xorone.in 2) node[left=0.5cm](b) {B}

(a.east) to[short,-*] (xorone.in 1) |- (and.in 1)
(b.east) to[short,-*] ($(b.east)!.5!(xorone.in 2)$) coordinate (branch)
    -- (xorone.in 2)
(branch) |- (and.in 2);  
\end{circuitikz}
\end{document} 

demo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.