![如何聲明自訂座標](https://rvso.com/image/392317/%E5%A6%82%E4%BD%95%E8%81%B2%E6%98%8E%E8%87%AA%E8%A8%82%E5%BA%A7%E6%A8%99.png)
我創建了這個範例圖,其中所有內容都與第一個 和 閘的輸入對齊。是否可以將它們替換([xshift=-15mm]bothNegated.bin 1)
為先前聲明的自訂表達式,這樣就不必一遍又一遍地重複相同的命令?
我正在使用電路圖包為反向輸入只是,其餘的就和Circuitikz中的一樣了。
我嘗試在交叉點使用節點,但線路([xshift=-5mm]bothNegated.bin 1) |- node[circ,midway]{} (notB.in 1)
未連接到通往頂部和大門的線路。
\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikzgit}
\begin{document}
\begin{circuitikz} \draw
(2,0) node[and port] (bothTrue) {}
(2,2) node[and port] (notB) {}
(2,4) node[and port] (notA) {}
(2,6) node[and port] (bothNegated) {}
([xshift=-15mm]bothNegated.bin 1) node[anchor=east] (Anode) {A}
([xshift=-15mm]bothNegated.bin 1) -| (bothNegated.in 1)
([xshift=-5mm]bothNegated.bin 1) node[circ]{} |- (bothTrue.in 1)
([xshift=-5mm]bothNegated.bin 1) |- node[circ,midway]{} (notB.in 1)
([xshift=-5mm]bothNegated.bin 1) |- node[circ,midway]{} (notA.in 1)
([xshift=-15mm]bothNegated.bin 2) node[anchor=east] {B}
([xshift=-15mm]bothNegated.bin 2) -| (bothNegated.in 2)
([xshift=-10mm]bothNegated.bin 2) node[circ]{} |- (bothTrue.in 2)
([xshift=-10mm]bothNegated.bin 2) |- node[circ,midway]{} (notA.in 2)
([xshift=-10mm]bothNegated.bin 2) |- node[circ,midway]{} (notB.in 2)
(bothNegated.bin 2) node[ocirc, left] {}
(bothNegated.bin 1) node[ocirc, left] {}
(notA.bin 2) node[ocirc, left] {}
(notB.bin 1) node[ocirc, left] {}
;\end{circuitikz}
\end{document}
答案1
您可以這樣定義座標:
\coordinate (c1) at ([xshift=-15mm]bothNegated.bin 1);
\coordinate (c2) at ([xshift=-15mm]bothNegated.bin 2);
\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikzgit}
\begin{document}
\begin{circuitikz}
\draw
(2,0) node[and port] (bothTrue) {}
(2,2) node[and port] (notB) {}
(2,4) node[and port] (notA) {}
(2,6) node[and port] (bothNegated) {};
\coordinate (c1) at ([xshift=-15mm]bothNegated.bin 1);
\coordinate (c2) at ([xshift=-15mm]bothNegated.bin 2);
\draw
(c1) node[anchor=east] (Anode) {A}
(c1) -| (bothNegated.in 1)
([xshift=10mm]c1) node[circ]{} |- (bothTrue.in 1)
([xshift=10mm]c1) |- node[circ,midway]{} (notB.in 1)
([xshift=10mm]c1) |- node[circ,midway]{} (notA.in 1)
(c2) node[anchor=east] {B}
(c2) -| (bothNegated.in 2)
([xshift=5mm]c2) node[circ]{} |- (bothTrue.in 2)
([xshift=5mm]c2) |- node[circ,midway]{} (notA.in 2)
([xshift=5mm]c2) |- node[circ,midway]{} (notB.in 2)
(bothNegated.bin 2) node[ocirc, left] {}
(bothNegated.bin 1) node[ocirc, left] {}
(notA.bin 2) node[ocirc, left] {}
(notB.bin 1) node[ocirc, left] {};
\end{circuitikz}
\end{document}