我正在制作电路图,希望每个输入具有相同的起始 x 坐标。我需要将 R 输入与 P 和 Q 对齐。
需要更改的行是分号前的倒数第二行。我尝试了“-|”符号,如下所示 (-1 -| a1.in 2),但没有成功。
这是我的代码:
\documentclass{article}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw
(-1,0) node[label=left:$P$] {} to[short,o-]
(0,0) node[or port, anchor=in 1] (o1) {}
(o1.in 2) to[short,-o] ++(-1,0) node[label=left:$Q$] {}
(o1.out) to ++(0.3,0) node[not port, anchor=in] (n1) {}
(n1.out) -| ++(0.5,-0.5) --
++(0.5,0) node[and port,anchor=in 1] (a1) {}
(a1.in 2) to[short,-o] ++(-3,0) node[label=left:$R$] {}
(a1.out) to[short,-o] ++(1,0) node[label=right:$S$] {}
;
\end{circuitikz}
\end{document}
这是输出:
答案1
简单的解决方案是命名包含 P 的节点并使用(P |- a1.in 2)
。要回答您的精确问题,请使用({-1,0} |- a1.in 2)
。
\documentclass{article}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw
(-1,0) node[label=left:$P$] (P) {} to[short,o-]
(0,0) node[or port, anchor=in 1] (o1) {}
(o1.in 2) to[short,-o] (P |- o1.in 2) node[label=left:$Q$] {}
(o1.out) to ++(0.3,0) node[not port, anchor=in] (n1) {}
(n1.out) -| ++(0.5,-0.5) --
++(0.5,0) node[and port,anchor=in 1] (a1) {}
(a1.in 2) to[short,-o] (P |- a1.in 2) node[label=left:$R$] {}
(a1.out) to[short,-o] ++(1,0) node[label=right:$S$] {}
;
\end{circuitikz}
\end{document}
答案2
用 Ti 做实验钾Z 库ext.paths.ortho
和inline not
逻辑门,基于@Koromylo 的精彩回答 (+1):
\documentclass[border=3.141592]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{ext.paths.ortho} % for -|- and |-| path operations
\begin{document}
\begin{circuitikz}
\draw (0,0) node[label=left:$P$] (P) {}
to[short,o-] ++ (0.5,0)
node[or port, anchor=in 1] (o1) {}
(o1.in 2) to[short,-o] (P |- o1.in 2)
node[label=left:$Q$] {}
(o1.out) to[inline not] ++ (2,0) % <---
-|- ++ (0.3,-0.5) % <---
node[and port,anchor=in 1] (a1) {}
(a1.out) to[short,-o] ++ (1,0)
node[label=right:$S$] {}
(a1.in 2) to[short,-o] (P |- a1.in 2)
node[label=left:$R$] {}
;
\end{circuitikz}
\end{document}