我正在画一个由大量 PMOS 晶体管组成的电子电路。它还具有两条路径相交的节点,我用实心圆圈标记这些节点。问题是我使用的是至[Tpmos]用于绘制晶体管,并且栅极中的填充圆看起来与那些节点填充圆完全相等。
我怎样才能改变 PMOS 晶体管的外观,使得栅极填充的圆圈显示为空白圆圈?
这是一个 MWE:
\documentclass[convert={density=600}]{standalone}
\usepackage{circuitikz}
\standaloneenv{circuitikz}
\begin{document}
\begin{circuitikz}[american currents]
\draw
(0,0) to[Tpmos, n=mp1] (0,2)
(0,2) to[short] (1,2)
(mp1.gate) to[short] ++(0,1) to [short, -*] ++(1,0);
\end{circuitikz}
\end{document}
结果如下:
问题是我希望 PMOS 门看起来与节点不同。也许可以通过用白色而不是黑色填充 PMOS 门的黑色圆圈来实现。
先谢谢了!
答案1
有点蛮力的方法。查看/usr/share/texlive/texmf-dist/tex/generic/circuitikz/pgfcirctripoles.tex
,复制并修改绘制圆圈和引导线的内容:
\documentclass[convert={density=600}, border=10pt]{standalone}
\usepackage{circuitikz}
\standaloneenv{circuitikz}
\makeatletter
\pgfcircdeclaremos{pmos}{
\anchor{S}{
\northeast
}
\anchor{source}{
\northeast
}
\anchor{D}{
\northeast
\pgf@y=-\pgf@y
}
\anchor{drain}{
\northeast
\pgf@y=-\pgf@y
}
}{%
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base width}\pgf@circ@res@left}
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@up}}
\pgfusepath{draw}
\ifpgf@circuit@mos@arrows
\pgfscope
\pgfslopedattimetrue
\pgfallowupsidedownattimetrue
\pgfresetnontranslationattimefalse
\pgftransformlineattime{.4}{%
\pgfpoint%
{\pgf@circ@res@right}%
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@up}%
}{%
\pgfpoint
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left}%
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@up}%
}
\pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
\endpgfscope
\fi
\pgfscope
\pgfpathmoveto{\pgfpoint
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base width}\pgf@circ@res@left}
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base height}\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base width}\pgf@circ@res@left}
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base height}\pgf@circ@res@down}}
\pgfsetlinewidth{2\pgflinewidth}
\pgfusepath{draw}
\endpgfscope
\pgfpathmoveto{\pgfpoint
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base width}\pgf@circ@res@left}
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
\pgfpathmoveto{\pgfpoint
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left}
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left}
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@down}}
\pgfpathmoveto{\pgfpoint %%% changed here to shorten the lead not to cross the circle
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left-2*\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}}
{\pgf@circ@res@up+\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+\pgf@circ@res@down}}
\pgfusepath{draw}
\pgfpathcircle{\pgfpoint
{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left - \pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}}
{\pgf@circ@res@up+\pgf@circ@res@down}}{\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}}
% removed the fill here
\pgfusepath{draw, }
\makeatother
}
\begin{document}
\begin{circuitikz}[american currents]
\draw
(0,0) to[Tpmos, n=mp1] (0,2)
(0,2) to[short] (1,2)
(mp1.gate) to[short] ++(0,1) to [short, -*] ++(1,0)
;
\end{circuitikz}
\end{document}
看起来工作量很大,但实际上修改很小:
- \pgfpathmoveto{\pgfpoint
- {\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left}
+ \pgfpathmoveto{\pgfpoint %%% changed here to shorten the lead not to cross the circle
+ {\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left-2*\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}}
{\pgf@circ@res@up+\pgf@circ@res@down}}
用于电线和:
- \pgfusepath{draw,fill}
-
+ % removed the fill here
+ \pgfusepath{draw, }
进行填充。
也许可以通过一些很好的修补咒语来实现etoolbox
...现在我看到它,我真的更喜欢新版本,所以也许只需修改原始文件并将其放入本地texmf
树中就可以了。
顺便说一句,似乎栅极引脚的位置并不完全在网格上。如果您这样做:
\draw
(0,0) to[Tpmos, n=mp1] (0,2)
(0,2) to[short, *-] (1,2)
(mp1.gate) to[short] ++(0,1)
to [short] ++(1,0)
;
您将摆脱那个不在连接中心的可怕的连接点......
答案2
现在有更好的解决方案!只需添加
\ctikzset{tripoles/pmos style/emptycircle}
到你的 circuitikz 环境。来源:https://github.com/circuitikz/circuitikz/issues/238#issuecomment-507619630