我想用欧式门绘制逻辑门结构。除了一件事外,使用 Circuitikz 效果很好:输入门的否定。我知道一种使用 ocirc 放置它们的方法,但我想在输出处放置一个像小三角形一样的小三角形(参见下面的 MWE)。我怎样才能使节点形状看起来像那样?
蒂亚·吉多
\documentclass[11pt,fleqn]{article}
\usepackage{circuitikz}
\tikzstyle{branch}=[fill,shape=circle,minimum size=3pt,inner sep=0pt]
\begin{document}
\begin{circuitikz}
\ctikzset{logic ports = european}
\draw
(0,2) node[and port] (and1) {}
(0,0) node[and port] (and2) {}
(2.5,1) node[nor port] (or1) {}
(and1.in 1) node[left=.2cm](a0) {$ A_0 $}
(and1.in 2) node[left = .2cm](a1) {$ A_1 $}
(and1.out) -| (or1.in 1)
(a0) -| (and1.in 1)
(a1) -| (and1.in 2)
(and2.in 2) node[left = .2cm](a0) {$ A_0 $}
(and2.out) -| (or1.in 2)
(a1 -| and2.in 1) node[branch] {} -- (and2.in 1)
(a0) -| (and2.in 2)
(or1.out) node [right=0.2] (x) {$X$}
;
\node at (and1.bin 1)[ocirc,left] {};
\node at (and2.bin 1)[ocirc,left] {};
\end{circuitikz}
\end{document}
答案1
嗯 --- 这将是一个非常不标准的符号,(至少基于https://github.com/circuitikz/circuitikz/issues/385),但您可以使用一个小宏来实现这一点(顺便说一句,我使用了circ
形状而不是您的branch
,以便与一个保持一致ocirc
):
\documentclass[11pt,fleqn]{article}
\usepackage[RPvoltages]{circuitikz}
\newcommand{\trianglenotin}[1]{% argument: input pin anchor to negate
\draw (#1) +(0, 3pt) -- +(-4pt,0);
}
\begin{document}
\begin{circuitikz}
\ctikzset{logic ports = european}
\draw
(0,2) node[and port] (and1) {}
(0,0) node[and port] (and2) {}
(2.5,1) node[nor port] (or1) {}
(and1.in 1) node[left=.2cm](a0) {$ A_0 $}
(and1.in 2) node[left = .2cm](a1) {$ A_1 $}
(and1.out) -| (or1.in 1)
(a0) -| (and1.in 1)
(a1) -| (and1.in 2)
(and2.in 2) node[left = .2cm](a0) {$ A_0 $}
(and2.out) -| (or1.in 2)
(a1 -| and2.in 1) node[circ] {} -- (and2.in 1)
(a0) -| (and2.in 2)
(or1.out) node [right=0.2] (x) {$X$}
;
% \node at (and1.bin 1)[ocirc,left] {};
% \node at (and2.bin 1)[ocirc,left] {};
\trianglenotin{and1.bin 1}
\trianglenotin{and2.bin 1}
\end{circuitikz}
\end{document}
您可以轻松地在宏中更改三角形的形状。
正如评论中所说(我不知道!),如果将宏更改为:
\newcommand{\trianglenotin}[1]{% argument: input pin anchor to negate
\draw (#1) ++(-4pt, 0) -- ++(0, 3pt) -- (#1);
}
反过来看,三角形是这样的:
...同时,您还可以添加边缘敏感输入...
\documentclass[11pt,fleqn]{article}
\usepackage[RPvoltages]{circuitikz}
\newcommand{\trianglenotin}[1]{% argument: input pin anchor to negate
\draw (#1) ++(-4pt, 0) -- ++(0, 3pt) -- (#1);
}
\newcommand{\addedgeinright}[1]{% argument: input pin anchor to add the edge to
\draw (#1) ++(0, 3pt) -- ++(3pt, -3pt) -- ++(-3pt, -3pt);
}
\begin{document}
\begin{circuitikz}
\ctikzset{logic ports = european}
\draw
(0,2) node[and port] (and1) {}
(0,0) node[and port] (and2) {}
(2.5,1) node[nor port] (or1) {}
(and1.in 1) node[left=.2cm](a0) {$ A_0 $}
(and1.in 2) node[left = .2cm](a1) {$ A_1 $}
(and1.out) -| (or1.in 1)
(a0) -| (and1.in 1)
(a1) -| (and1.in 2)
(and2.in 2) node[left = .2cm](a0) {$ A_0 $}
(and2.out) -| (or1.in 2)
(a1 -| and2.in 1) node[circ] {} -- (and2.in 1)
(a0) -| (and2.in 2)
(or1.out) node [right=0.2] (x) {$X$}
;
\trianglenotin{and1.bin 1}
\trianglenotin{and2.bin 1}
\addedgeinright{and2.bin 2}
\end{circuitikz}
\end{document}
...相对坐标绘制非常有用!