带有 circuitikz 的逻辑门

带有 circuitikz 的逻辑门

我需要一些帮助来进行对齐以及如何仅使用一个 A、B 和 C 来修复所有逻辑门。

\begin{circuitikz} \draw

(0,4) node[not port, scale=.5](mynotA){}

(mynotA.in) node[left=1](a) {A}

(a) -- (mynotA.in)

(0,3.2) node[not port, scale=.5](mynotB){}

(mynotB.in) node[left = 1](b) {B}

(b) -- (mynotB.in)

(2.5,3.5) node[and port] (myand) {}

(mynotA.out) -| (myand.in 1)

(mynotB.out) -| (myand.in 2)


(4,3) node[and port] (myand1) {}

(myand.out) -- (myand1.in 1)

(myand1.in 2) node[left=3.95](c) {C}

(c) -| (myand1.in 2)


(0,2) node[not port, scale=.5](mynotA1){}

(mynotA1.in) node[left=1](a1) {A}

(a1) -- (mynotA1.in)

(0,1) node[not port, scale=.5](mynotC){}

(mynotC.in) node[left = 1](c1) {C}

(c1) -- (mynotC.in)

(2.5,1.8) node[and port] (myand2) {}

(mynotA1.out) -| (myand2.in 1)

(myand2.in 2) node[left=2.5](b1) {B}

(b1) -| (myand2.in 2)

(4,1.5) node[and port] (myand3) {}

(myand2.out) -| (myand3.in 1)

(mynotC.out) -| (myand3.in 2)

(2.5,0) node[and port] (myand4) {}

(myand4.in 1) node[left=2.5](a2) {A}

(myand4.in 2) node[left=2.5](b2) {B}

(a2) -| (myand4.in 1)

(b2) -| (myand4.in 2)

(4,-0.5) node[and port] (myand5) {}

(myand4.out) -| (myand5.in 1)

(myand5.in 2) node[left=4](c2) {C}

(c2) -| (myand5.in 2)

;
\end{circuitikz}

答案1

使用[anchor=in 1][anchor=in 2]可以将组件放置在与其他组件的输出精确对齐的位置。

\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}

\begin{circuitikz} 
\draw
(0,4) node[not port, scale=.5](mynotA){}
(mynotA.in) node[left=1](a) {A}
(a) -- (mynotA.in)
(0,3.2) node[not port, scale=.5](mynotB){}
(mynotB.in) node[left = 1](b) {B}
(b) -- (mynotB.in)
(mynotB.out) node[and port,anchor=in 2] (myand) {}
(mynotA.out) -| (myand.in 1)
%(mynotB.out) -| (myand.in 2)
(myand.out) node[and port,anchor=in 1] (myand1) {}
%(myand.out) -| (myand1.in 1)
(myand1.in 2) node[left=3.95](c) {C}
(c) -- (myand1.in 2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(0,2) node[not port, scale=.5](mynotA1){}
(mynotA1.in) node[left=1](a1) {A}
(a1) -- (mynotA1.in)
(0,1) node[not port, scale=.5](mynotC){}
(mynotC.in) node[left = 1](c1) {C}
(c1) -- (mynotC.in)
(mynotA1.out) node[and port,anchor=in 1] (myand2) {}
%(mynotA1.out) -| (myand2.in 1)
(myand2.in 2) node[left=2.5](b1) {B}
(b1) -| (myand2.in 2)
(myand2.out) node[and port,anchor=in 1] (myand3) {}
%(myand2.out) -| (myand3.in 1)
(mynotC.out) -| (myand3.in 2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(2.5,0) node[and port] (myand4) {}
(myand4.in 1) node[left=2.5](a2) {A}
(myand4.in 2) node[left=2.5](b2) {B}
(a2) -| (myand4.in 1)
(b2) -| (myand4.in 2)
(myand4.out) node[and port,anchor=in 1] (myand5) {}
%(myand4.out) -| (myand5.in 1)
(myand5.in 2) node[left=4](c2) {C}
(c2) -| (myand5.in 2)
;
\end{circuitikz}
\end{document}

演示

相关内容