![带倒置气泡的电路缓冲器输入](https://linux22.com/image/476767/%E5%B8%A6%E5%80%92%E7%BD%AE%E6%B0%94%E6%B3%A1%E7%9A%84%E7%94%B5%E8%B7%AF%E7%BC%93%E5%86%B2%E5%99%A8%E8%BE%93%E5%85%A5.png)
相关问题Circuitikz 逆变器气泡演示了如何反转 AND 门上的输入。如何在缓冲门上执行此操作?(向右三角形)我似乎找不到文档。我尝试使用,node[buffer, inputs=i]
但它似乎无法识别inputs
密钥。
更新:看起来我可以在元素中执行此操作,tikzpicture
但不能在元素内部执行此circuitikz
操作。以下方法有效,但我需要将其组合起来并连接到元素中的某些内容circuitikz
:
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{circuits.logic.US}
\begin{document}
\begin{tikzpicture}[circuit logic US]
\node (a) [buffer gate, inputs=i] {};
\end{tikzpicture}%
\end{document}
有没有办法在 circuitikz 绘图中使用它?
答案1
\buffergate
一种可能的解决方案是通过语法定义一个缓冲门,\newcommand
该语法采用两个参数#1=name
和#2= rotation angle
。建议的解决方案将重新定义not port
为\buffergate
,以便缓冲门可以在circuitiz
图形内部使用。借用了来自的示例circuitikz
,并遵循建议。
\newcommand{\buffergate}[2]
{ % #1 = name , #2 = rotation angle
\begin{scope}[transform shape,rotate=#2]
\draw[thick] (#1) ++(-16pt,0) coordinate[ocirc,xshift=-2pt](#1in) -- ++(0,16pt) -- ++
(30pt,-16pt)coordinate(a) -- ++(-30pt,-16pt) -- cycle;
\draw (a) --++(6pt,0)coordinate(#1out);
\end{scope}
}
背后的逻辑是调用not port
,用白色为其着色,赋予其标签名称,使用命令\bufergate
,如下所示。
\draw (1,0) node[not port,color=white,name=not1] () {};
\buffergate{not1}{0} % 0 = horizontal
代码
\documentclass[border=10pt,varwidth]{standalone}
\usepackage{tikz}
\usepackage[american,siunitx]{circuitikz}
\usetikzlibrary{calc,positioning}
\newcommand{\buffergate}[2]
{ % #1 = name , #2 = rotation angle
\begin{scope}[transform shape,rotate=#2]
\draw[thick] (#1) ++(-16pt,0) coordinate[ocirc,xshift=-2pt](#1in) -- ++(0,16pt) -- ++(30pt,-16pt)coordinate(a) -- ++(-30pt,-16pt) -- cycle;
\draw (a) --++(6pt,0)coordinate(#1out);
\end{scope}
}
\begin{document}
An example from circuitikz
\begin{circuitikz}
\draw
(1,0) node[not port] (not1) {}
(3,0) node[not port] (not2) {}
(0,0) -- (not1.in)
(not2.in) -- (not1.out)
++(0,-1) node[ground] {} to [C] (not1.out)
(not2.out) -| (4,1) -| (0,0);
\end{circuitikz}
\medskip
Proposed solution 1 -- node
\medskip
\begin{circuitikz}
\draw
(1,0) node[not port,color=white,name=not1] () {};
\buffergate{not1}{0}
\draw (3,0) node[not port,color=white,name=not2] () {};
\buffergate{not2}{-90}
\draw (0,0) -- (not1.in);
\draw(1.7,-1) node[ground] {} to [C] (not1out)
(not2out) -| (4,1) -| (0,0);
\draw (not1out) --++(0.5,0)|- (not2in);
\end{circuitikz}
\medskip
Proposed solution 2 -- path
\medskip
\begin{circuitikz}
\path(0.5,0) to[not port,color=white,name=not1] (1.5,0);
\buffergate{not1}{0}
\path(2.5,0) to[not port,color=white,name=not2] (3.5,0);
\buffergate{not2}{90}
\draw (0,0) -- (not1in);
\draw (1.7,-1) node[ground] {} to [C] (not1out)
(not2out) -| (4,1) -| (0,0);
\draw (not1out) --++(0.5,0)|- (not2in);
\end{circuitikz}
\end{document}