我使用下面显示的代码绘制了一个静态 CMOS 反相器。我尝试使用 TikZ 库 calc 来计算 PMOS 和 NMOS 器件漏极相交的点;以及连接两个器件栅极的线的中点。显然 calc 正确地得到了这些点的 y 坐标。但是,calc 似乎错误地得到了这些点的 x 坐标。我可能做错了什么?
以下是 TikZ 代码:
\documentclass{standalone}
\usepackage[americaninductors]{circuitikz}
\usetikzlibrary{calc}
\begin{document}
\begin{circuitikz}
\draw
% Draw MOSFETs:
(0,0) node [pigfete,yscale=-1,anchor=S] (M1) {}
(M1.D) node[nigfete,anchor=D] (M2) {}
(M1.G)--(M2.G) % The line connecting the gates of the MOSFETs.
;
% Draw the power rails:
\draw ($(M1.S)-(2.0,0)$) -- (M1.S) -- ($(M1.S)+(1.2,0)$);
\draw ($(M2.S)-(2.0,0)$) -- (M2.S) -- ($(M2.S)+(1.2,0)$);
% Input and output nodes:
\node (I) at ($0.5*(M2.G)+0.5*(M1.G)$) {}; % The mid-point between the gates.
\node (O) at (M1.D) {}; % The point at which the drains of the MOSFETs are conneted.
% The Input and output lines.
\draw ($(I)-(.8,0)$) -- (I);
\draw (O) -- ($(O)+(0.8,0)$);
\end{circuitikz}
\end{document}
这是我得到的数字:请注意,输入和输出线未连接到电路的其余部分。我们能否将线路未连接到电路其余部分的问题归咎于我使用计算的方式?
答案1
结果:
代码:
\documentclass{standalone}
\usepackage[americaninductors]{circuitikz}
\usetikzlibrary{calc}
\begin{document}
\begin{circuitikz}
\draw
% Draw MOSFETs:
(0,0) node [pigfete,yscale=-1,anchor=S] (M1) {}
(M1.D) node[nigfete,anchor=D] (M2) {}
(M1.G)--(M2.G) % The line connecting the gates of the MOSFETs.
;
% Draw the power rails:
\draw ($(M1.S)-(2.0,0)$) -- (M1.S) -- ($(M1.S)+(1.2,0)$);
\draw ($(M2.S)-(2.0,0)$) -- (M2.S) -- ($(M2.S)+(1.2,0)$);
% Input and output nodes:
%\node (I) at ($0.5*(M2.G)+0.5*(M1.G)$) {}; % The mid-point between the gates.
\coordinate (I) at ($0.5*(M2.G)+0.5*(M1.G)$); % The mid-point between the gates.
%\node[outer sep=0pt,inner sep=0pt] (O) at (M1.D) {}; % The point at which the drains of the MOSFETs are conneted.
\coordinate (O) at (M1.D); % The point at which the drains of the MOSFETs are conneted.
% The Input and output lines.
\draw (I) -- ++(-0.8,0);
\draw (O) -- ++(0.8,0);
\end{circuitikz}
\end{document}
说明:
TikZ\node
会在它们周围添加一定的填充(在外部,由 给出outer sep
,在内部,由 给出)inner sep
。为了防止出现这种额外的空间,最好使用\coordinate
。另一种选择是sep
使用以下方法杀死这些 s\node[inner sep=0pt,outer sep=0pt] {};