我正在尝试正确放置标签,并可能延长从 NAND2.in 1 和 NAND2.in 2 节点出来的线路,这样我的第一个电路在标签排列方面看起来与第二个电路相似。我查看了 CircuitTikz 手册,但无法解决我的问题。
\documentclass[12pt]{article}
\import{circuitikz}
\begin{document}
\subsection*{(b) }
\begin{center}
\begin{tikzpicture}
\node[nand port] (NAND1) {};
\node[nand port] at ($(NAND1) + (2,0)$) (NAND2) {};
\draw (NAND1.in 1) -- ++(-0.5,0) node[left ] {$p$};
\draw (NAND1.in 2) -- ++(-0.5,0) node[left ] {$q$};
\draw (NAND2.in 1) node[above] {$\overline{p \land q}$};
\draw (NAND2.in 2) node[below] {$\overline{p \land q}$};
\draw (NAND1.out) -| (NAND2.in 1) -| (NAND2.in 2);
\draw[->] (NAND2.out) -- ++( 0.5,0) node[right] {$\overline{\overline{p \land q} \land \overline{p \land q}} \equiv \overline{\overline{p \land q}} \equiv p \land q$};
\end{tikzpicture}
\end{center}
\subsection*{(c) }
\begin{center}
\begin{tikzpicture}
\node[nand port] (NAND1) {};
\node[nand port] at ($(NAND1) + (0,-1.5)$) (NAND2) {};
\node[nand port] at ($(NAND1) + (2,-0.75)$) (NAND3) {};
\draw (NAND1.in 1) -- ++(-0.5,0) node[left ] {$p$};
\draw (NAND1.in 2) -- ++(-0.5,0) node[left ] {$p$};
\draw (NAND2.in 1) -- ++(-0.5,0) node[left ] {$q$};
\draw (NAND2.in 2) -- ++(-0.5,0) node[left ] {$q$};
\draw (NAND1.out) node[above] {$\overline{p}$};
\draw (NAND2.out) node[below] {$\overline{q}$};
\draw (NAND1.out) -| (NAND3.in 1);
\draw (NAND2.out) -| (NAND3.in 2);
\draw[->] (NAND3.out) -- ++( 0.5,0) node[right] {$\overline{\overline{p} \land \overline{q}} \equiv \overline{\overline{p}} \lor \overline{\overline{q}} \equiv p \lor q$};
\end{tikzpicture}
\end{center}
\end{document}
答案1
xshift
使用和 的简单解决方案yshift
:
\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{tikzpicture}
\node[nand port] (NAND1) {};
\node[nand port] at ($(NAND1) + (2,0)$) (NAND2) {};
\draw (NAND1.in 1) -- ++(-0.5,0) node[left ] {$p$};
\draw (NAND1.in 2) -- ++(-0.5,0) node[left ] {$q$};
\draw (NAND2.in 1) node[above,yshift=0mm,xshift=-3.5mm] {$\overline{p \land q}$};
\draw (NAND2.in 2) node[below,yshift=-1mm,xshift=-3.5mm] {$\overline{p \land q}$};
\draw (NAND1.out) -| (NAND2.in 1) -| (NAND2.in 2);
\draw[->] (NAND2.out) -- ++( 0.5,0) node[right] {$\overline{\overline{p \land q} \land \overline{p \land q}} \equiv \overline{\overline{p \land q}} \equiv p \land q$};
\end{tikzpicture}
\end{document}