How can i draw a circuit like this using circuitikz?
-
1Welcome to TeX.SE! What you try so far? For logic gates see CircuiTikZ manual, section 3.24 Logic gates, page 97. At bottom of the page 101 you can find some examples of elementary logic circuits. This can serve for starting point. Also see tex.stackexchange.com/questions/174663/… and tex.stackexchange.com/questions/332639/…. Both questions are quite similar what you like to draw.– ZarkoFeb 23, 2020 at 13:41
-
Thank you for your comment! I looked at them both but couldn't make it at all.– electromanFeb 23, 2020 at 13:55
-
Have you spent your four or five hours to give it a real try? Unless you're asking for someone to draw your circuit for you, that's about the minimum amount of time you need to learn to do anything useful in circuitikz from a zero start– Scott SeidmanFeb 23, 2020 at 14:13
-
Thank you for your suggestions. I will make it like that after this time. Sorry for taking time– electromanFeb 23, 2020 at 15:17
-
And also how can i learn circuitikz very well? Any other sources than documentation?– electromanFeb 23, 2020 at 15:18
1 Answer
The following draws your logic circuit. Everything is placed relative to A and if you change something in the A path, the B path should stretch/shrink accordingly.
\documentclass[border=3.14,tikz]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw (0,0) coordinate[label={[left]$A$}](A)
to[short,-*] ++(.35,0) coordinate(jA)
-- ++(.25,0) node[american not port, anchor=west](notA){} (notA.east)
node[american and port, anchor=in 1](andA){}
(A) ++(0, -2) coordinate[label={[left]$B$}](B)
to[short,-*] ($(B-|jA)+(0.1,0)$) coordinate(jB)
-- (B-|notA.west) node[american not port, anchor=west](notB){} (notB.east)
node[american and port, anchor=in 2](andB){}
(jA) -- ($(jA)!.8!(jA|-andB.in 1)$) -| (andB.in 1) -- +(.01,0)
(jB) -- ($(jB)!.8!(jB|-andA.in 2)$) -| (andA.in 2) -- +(.01,0)
($(A)!.5!(B)$) coordinate(vc)
(vc-|andB.out) node[american or port, anchor=west](or){}
(andA.out) ++(-.01,0) -| (or.in 1) -- +(0.01,0)
(andB.out) ++(-.01,0) -| (or.in 2) -- +(0.01,0)
(or.out) node[right]{$(\bar{A}\cdot B)+(A\cdot\bar{B})=A\oplus B$}
;
\end{tikzpicture}
\end{document}