CircuiTikZ 自己的组件定义:软件包较新版本出现错误

CircuiTikZ 自己的组件定义:软件包较新版本出现错误

我定义了一个自定义的 nigfete 节点样式组件,在安装 CircuiTikZ 软件包 1.3.4 版之前,我一直使用它,没有任何问题。但是,现在我收到“未定义控制序列”错误,我无法解决。

请参阅以下 MWE,它重新定义了 nigfete 的一些基本参数,并在门连接处添加了一个点。该示例在 1.3.4 之前的 CircuiTikZ 版本中按预期运行:

\documentclass[]{standalone}
\usepackage{circuitikzgit}
% Save the appropriate style file from https://circuitikz.github.io/circuitikz/ as circuitikzgit.sty 
% in the project folder; MWE works for versions < 1.3.4.

% Slight adjustments of the nigfete parameters
\makeatletter
\ctikzset{tripoles/mynigfete/width/.initial=.6}
\ctikzset{tripoles/mynigfete/gate height/.initial=.546}
\ctikzset{tripoles/mynigfete/base height/.initial=.65}
\ctikzset{tripoles/mynigfete/conn height/.initial=.546}
\ctikzset{tripoles/mynigfete/height/.initial=0.8}
\ctikzset{tripoles/mynigfete/bodydiode scale/.initial=.3}
\ctikzset{tripoles/mynigfete/bodydiode distance/.initial=.3}
\ctikzset{tripoles/mynigfete/bodydiode conn/.initial=.546}
\ctikzset{tripoles/mynigfete/curr direction/.initial=1}

\pgfdeclaretransistorwrapperaddbulk{mynigfete}{}{%
    \pgf@circuit@trans@depletiontypefalse
    \drawfetcore{nigfete}
    
    % SOURCE CONNECTION
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfusepath{draw}
    
    % SOLDER DOT at source-bulk connection
    \ifpgf@circuit@fet@solderdot
        \pgfscope
            \pgftransformshift{\pgfpoint{\pgf@circ@res@right}{
                \ctikzvalof{tripoles/nigfete/gate height}\pgf@circ@res@down}}
            \pgfnode{circ}{center}{}{}{}
        \endpgfscope{}
    \fi
    
    %% Gate Dot - Modification
    \pgfscope
        \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{
            \ctikzvalof{tripoles/nigfete/gate height}\pgf@circ@res@down}}
        \pgfnode{ocirc}{center}{}{}{}
    \endpgfscope{}
    %%
}
\pgf@circ@definetranspath{mynigfete}

\makeatother

\begin{document}
    \begin{tikzpicture}
        \draw (0,0) node[mynigfete] (S1) {};
    \end{tikzpicture}
\end{document}

答案1

除了\makeatletter代码中缺少什么(我在\ctikzsets 后面添加的)之外,让我们看看会发生什么——这可能会在将来有所帮助:

p1d/1& [romano:~/tmp] % pdflatex lilla.tex
[...]
! Undefined control sequence.
\pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@ 
                                                  
l.52         \draw (0,0) node[mynigfete] (S1) {};
                                                 
? 

现在按enter

! Missing number, treated as zero.
<to be read again> 
                   \pgfk@/tikz/circuitikz/tripoles/mynigfete/base width 
l.52         \draw (0,0) node[mynigfete] (S1) {};
                                                 
? 

因此核心宏正在寻找一个base width不在这里的维度。可能是在重新组织晶体管定义和添加圆圈时我添加了它(现在记不清了,忘记了如何使用git blame)。将其添加为

\ctikzset{tripoles/mynigfete/base width/.initial=.5}

和...

在此处输入图片描述

完整代码:

\documentclass[]{standalone}
\usepackage{circuitikz}
% Save the appropriate style file from https://circuitikz.github.io/circuitikz/ as circuitikzgit.sty 
% in the project folder; MWE works for versions < 1.3.4.

% Slight adjustments of the nigfete parameters
\ctikzset{tripoles/mynigfete/width/.initial=.6}
\ctikzset{tripoles/mynigfete/gate height/.initial=.546}
\ctikzset{tripoles/mynigfete/base height/.initial=.65}
\ctikzset{tripoles/mynigfete/conn height/.initial=.546}
\ctikzset{tripoles/mynigfete/height/.initial=0.8}
\ctikzset{tripoles/mynigfete/bodydiode scale/.initial=.3}
\ctikzset{tripoles/mynigfete/bodydiode distance/.initial=.3}
\ctikzset{tripoles/mynigfete/bodydiode conn/.initial=.546}
\ctikzset{tripoles/mynigfete/curr direction/.initial=1}
% \ctikzset{tripoles/mynigfete/base width/.initial=.5}
\makeatletter

\pgfdeclaretransistorwrapperaddbulk{mynigfete}{}{%
    \pgf@circuit@trans@depletiontypefalse
    \drawfetcore{nigfete}
    
    % SOURCE CONNECTION
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfusepath{draw}
    
    % SOLDER DOT at source-bulk connection
    \ifpgf@circuit@fet@solderdot
        \pgfscope
            \pgftransformshift{\pgfpoint{\pgf@circ@res@right}{
                \ctikzvalof{tripoles/nigfete/gate height}\pgf@circ@res@down}}
            \pgfnode{circ}{center}{}{}{}
        \endpgfscope{}
    \fi
    
    %% Gate Dot - Modification
    \pgfscope
        \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{
            \ctikzvalof{tripoles/nigfete/gate height}\pgf@circ@res@down}}
        \pgfnode{ocirc}{center}{}{}{}
    \endpgfscope{}
    %%
}

\pgf@circ@definetranspath{mynigfete}

\makeatother

\begin{document}
    \begin{tikzpicture}
        \draw (0,0) node[mynigfete] (S1) {};
    \end{tikzpicture}
\end{document}

顺便说一句:找到了,我在 2021-01-04 将其添加到重新组织晶体管的定义中。因此,您修改后的晶体管将在 1.3.0 开始失效。这是使用内部接口的风险 --- 对此深表歉意。

1d [romano:~/software/ … /my-circuitikz/tex] master 128 ± git log -u -L 3059,3063:pgfcirctripoles.tex
commit 8b2f1db5973fa73d9d8c2cef44c1f28a12cae340
Author: Romano Giannetti <[email protected]>
Date:   Mon Jan 4 16:54:23 2021 +0100

    Group transistors (and the strandled switch)

diff --git a/tex/pgfcirctripoles.tex b/tex/pgfcirctripoles.tex
--- a/tex/pgfcirctripoles.tex
+++ b/tex/pgfcirctripoles.tex
@@ -1586,0 +1803,5 @@
+\ctikzset{tripoles/nigfete/conn height/.initial=.35}
+\ctikzset{tripoles/nigfete/height/.initial=1.1}
+\ctikzset{tripoles/nigfete/base width/.initial=.5}
+\ctikzset{tripoles/nigfete/gate width/.initial=.62}
+\ctikzset{tripoles/nigfete/bodydiode scale/.initial=.3}

相关内容