3

My goal is to have a diagram which looks like this: result

I would like to accomplish this with the circuitikz-package. So far I have already written this piece of code:

\begin{circuitikz} \draw
    (0,2) node[and port] (and) {}
    (0,0) node[xor port] (xor) {}
    (and.in 1) node[above left=.5cm](a) {$a_0$}
    (and.in 2) node[below left = .5cm](b) {$b_0$}
    (and.out) node[below](s) {$s_1$}
    (xor.out) node[below](s) {$s_0$}    
    (a) -| (and.in 1)
    (b) -| (and.in 2)
    (a) -| (xor.in 1)
    (b) -| (xor.in 2);  
\end{circuitikz}

Which leads to this result: result_so_far

I would be more than happy, if you could help me to get the second image look more like the first one. Many thanks!

Edit: I just managed to get an image which is a bit better, by changing the position in the third line from (0,0) to (2,2)

Since this is just a dirty hack which dosn't scale to more complex diagrams, I would still appreciate help for a more general solution!

3

The main change is to have separate x coordinates for the vertical lines, changing e.g.

(a) -| (and.in 1)
(a) -| (xor.in 1)

to

(a) -- +(0.5,0) |- (and.in 1)
(a) -- +(0.5,0) |- (xor.in 1)

To make the circuit look even more like the sample circuit, one might want to move a_0 down.

enter image description here

\documentclass{article}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz} \draw
    (0,2) node[and port] (and) {}
    (0,0) node[xor port] (xor) {}
    (and.in 1) node[below left=.5cm](a) {$a_0$}
    (and.in 2) node[below left = .5cm](b) {$b_0$}
    (and.out) node[below](s) {$s_1$}
    (xor.out) node[below](s) {$s_0$}    
    (a) -- +(0.5,0) |- (and.in 1)
    (b) -| (and.in 2)
    (a) -- +(0.5,0) |- (xor.in 1)
    (b) -| (xor.in 2);  
\end{circuitikz}
\end{document}
| improve this answer | |

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.