# How to draw a Boolean circuit using circuitikz

How to draw circuit like the following using circuitikz . Also, I would like to know how to add dashed boxes in some part of the circuit

• Welcome to TexSE. In order to help you, we need to see what you've already tried in a "My working example" with a minimum code of yours. In other words, help us, help you :) As a start, check maybe tex.stackexchange.com/questions/32839/… or tex.stackexchange.com/questions/32839/… I found them through on Google with site:tex.stackexchange.com <Boolean circuit circuitikz> and checked images.
– JeT
Commented Jun 18, 2020 at 16:55
• Which boxes do you want to dash, there are no dashed boxes in your circuit? Commented Jun 18, 2020 at 20:33
• I want to add a dashed box for example for the AND and the XOR gates together, I mean a big box contain both of them Commented Jun 20, 2020 at 2:04
• @Nehad to do that, use my code from the answer and add \node[fit=(xor)(and), draw, dashed] {}; at the end. Commented Jun 20, 2020 at 14:52
• @TobiBS It does not work in my overleaf file the same as multiwire :(. No another way to do so?. Commented Jun 20, 2020 at 18:01

Maybe you want to start playing around with this and ask some more specific questions?

\documentclass[tikz]{standalone}

\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}
\draw
(1,0) node[twoportshape, t=S'] (ss) {}
(2,1.5) node[twoportshape, t=S] (s) {}
(3,0) node[twoportshape, t=G] (g) {}
(4,1.5) node[twoportshape, t=G] (gg) {}
(3,3) node[twoportshape, t=R] (r) {}
(8,2.25) node[and port] (and) {}
(12,0.75) node[xor port] (xor) {}
(and.out) to[multiwire=$\rho$] ++ (1,0) -| (xor.in 1)
(g.right) to[multiwire=$\rho$] ++ (1,0) -| (xor.in 2)
(r.right) to[multiwire=$\rho$] ++ (1,0) -| (and.in 1)
(gg.right) to[multiwire=$\rho$] ++ (1,0) -| (and.in 2)
(s.right) to[multiwire=$n$] ++ (1,0) -- (gg.left)
(ss.right) to[multiwire=$n$] ++ (1,0) -- (g.left)
(0,3)node[left]{b} -- (r.left)
(0,1.5)node[left]{0} -- (s.left)
(0,0)node[left]{0} -- (ss.left)
(xor.out) to[multiwire=$\rho$] ++ (1,0)node[right]{c};
\end{circuitikz}

\end{document}

• Thank you very much Commented Jun 20, 2020 at 1:55
• multiwire does not work What can I do?. My tex file doesn't recognize the multiwire command. also if you can teach me how ho add text in top of the wire? Commented Jun 20, 2020 at 2:41
• @NehadMabrouk, check if you have installed the last version of the circuitikz package (version 1.1.2 (2020/05/17) ). For labels of multiwire see package documentation, subsection 3.12 Multiple wires (buses), page 58--59. Commented Jun 20, 2020 at 2:46
• @Zarko I am using an online tex editor (overleaf). Commented Jun 20, 2020 at 2:48
• @NehadMabrouk, than you need to ask Overleaf support for help. Unfortunately, they do not upgrade their LaTeX installation enough frequently :-(. Commented Jun 20, 2020 at 2:52