\documentclass{article}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz} \draw
(0,3) node[not port] (mynot1) {}
(mynot1.in) node[anchor=east] {$r$}
(mynot1.out) node[anchor=south] {$\neg r$}
(0,1) node[not port] (mynot2) {}
(mynot2.in) node[anchor=east] {$q$}
(mynot2.out) node[anchor=south] {$\neg q$}
(3,4) node[and port] (myand1) {}
(myand1.in 1) node[anchor=east] {$p$}
(myand1.out) node[anchor=west] {$p \wedge \neg r$}
(3,0) node[and port] (myand2) {}
(myand2.in 2) node[anchor=east] {$r$}
(myand2.out) node[anchor=west] {$\neg q \wedge r$}
(mynot1.out) -| (myand1.in 2)
(mynot2.out) -| (myand2.in 1)
(5,2) node[or port] (myor) {}
(myor.out) node[anchor=west] {$(p \wedge \neg r) \vee (\neg q \wedge r)$}
(myand1.out) |- (myor.in 1)
(myand2.out) |- (myor.in 2)
;\end{circuitikz}
\end{document}
以上是我使用 circuitikz 包绘制逻辑电路的方法。我基本上能弄清楚如何绘制电路,但它看起来很丑,看
1)我希望它看起来更美观,即更小的“非”门,彩色的标签文本,更紧凑的定位,输入和输出上的箭头等,就像这样的风格:
任何想法?
答案1
这是第一种方法,采用更小的逻辑电路,具有更紧凑的定位和彩色标签文本。
\documentclass{article}
\usepackage{fullpage}
\usepackage[american]{circuitikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{circuitikz}[every label/.style={blue}]
\draw
% draw And1 gate with label then Not1 gate with label
(3,3) node[and port] (myand1) {}
(-1,3.3) node[label=left:$p$] {} -- (myand1.in 1)
(myand1.out) node[label=right:$p \wedge \neg r$] {}
(0,2.75) node[scale=0.7,not port] (mynot1) {}
(-1,2.75)node[label=left:$r$] {} -- (mynot1.in)
(mynot1.out) node[label=above:$\neg r$] {}
(mynot1.out) -- (myand1.in 2)
% draw And2 gate with label then Not2 gate with label
(3,1) node[and port] (myand2) {}
(-1,0.75) node[label=left:$r$] {} -- (myand2.in 2)
(myand2.out) node[label=right:$\neg q \wedge r$] {}
(0,1.3) node[scale=0.7,not port] (mynot2) {}
(-1,1.3) node[label=left:$q$] {} -- (mynot2.in)
(mynot2.out) node[label=above:$\neg q$] {}
(mynot2.out) -- (myand2.in 1)
% draw Or gate with inputs and output label
(6,2) node[or port] (myor) {}
(myand1.out) |- (myor.in 1)
(myand2.out) |- (myor.in 2)
(myor.out) -- (8,2) node[label=above:$(p \wedge \neg r) \vee (\neg q \wedge r)$] {}
;
\end{circuitikz}
\end{document}