我想将XOR
门的输出与这样的门input 1
对齐NAND
但是,使用以下代码,我无法获得完美的对齐
\documentclass{article}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}
\begin{figure}[h!]
\begin{circuitikz}
\draw
(0,0) node[xor port] (xor1) {}
(2,0.3) node[nand port] (nand1) {}
;\end{circuitikz}
\end{figure}
\end{document}
有没有办法实现完美对齐?
答案1
像这样?
\documentclass[border=5]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) node[xor port](xor1) {} to
(2,0) node[scale=1.2,nand port,anchor=in 1] (nand1) {}
(nand1.in 2) -- (xor1.in 2|-nand1.in 2)
;\end{circuitikz}
\end{document}
另一扇门:
\documentclass[border=5]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) node[xor port](xor1) {} to
(2,0) node[scale=1.2,nand port,anchor=in 1] (nand1) {}
(nand1.out) to +(2,0) node[scale=1.3,xor port,anchor=in 1] (xor2) {} %% 3rd gate
(nand1.in 2) -- (xor1.in 2|-nand1.in 2)
(xor2.in 2) -- (xor1.in 2|-xor2.in 2)
;\end{circuitikz}
\end{document}
实际上您不必对齐它们,因为可以轻松连接它们。
\documentclass[border=5]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) node[xor port](xor1) {}
(2,-1) node[nand port] (nand1) {}
(xor1.out) -| (nand1.in 1) %% connect them
(nand1.in 2) -- +(-2,0)
;\end{circuitikz}
\end{document}