1

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

Nehad
  • 77
  • 1
    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 https://tex.stackexchange.com/questions/32839/drawing-circuit-diagrams-with-logic-gates-in-latex or https://tex.stackexchange.com/questions/32839/drawing-circuit-diagrams-with-logic-gates-in-latex I found them through on Google with site:tex.stackexchange.com and checked images. – JeT Jun 18 '20 at 16:55
  • Which boxes do you want to dash, there are no dashed boxes in your circuit? – TobiBS Jun 18 '20 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 – Nehad Jun 20 '20 at 02:04
  • @Nehad to do that, use my code from the answer and add \node[fit=(xor)(and), draw, dashed] {}; at the end. – TobiBS Jun 20 '20 at 14:52
  • @TobiBS It does not work in my overleaf file the same as multiwire :(. No another way to do so?. – Nehad Jun 20 '20 at 18:01
  • @Nehad sorry I forgot to mention this requires a \usetikzlibrary{fit} in the preamble. – TobiBS Jun 20 '20 at 19:21
  • @TobiBS for multiwire which library I have to use? – Nehad Jun 20 '20 at 19:25
  • @Nehad, why are you trying to edit my answer? If you have different requirements, please modify your question, or ask an additional question. – TobiBS Jun 22 '20 at 22:49

1 Answers1

2

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

enter image description here

\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}

TobiBS
  • 5,240
  • Thank you very much – Nehad Jun 20 '20 at 01: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? – Nehad Jun 20 '20 at 02: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. – Zarko Jun 20 '20 at 02:46
  • @Zarko I am using an online tex editor (overleaf). – Nehad Jun 20 '20 at 02:48
  • @NehadMabrouk, than you need to ask Overleaf support for help. Unfortunately, they do not upgrade their LaTeX installation enough frequently :-(. – Zarko Jun 20 '20 at 02:52