修改 CircuiTikz 中的 PMOS 定义

修改 CircuiTikz 中的 PMOS 定义

我正在尝试按照以下说明修改 circuitikz 中的 pmos 定义这个答案但我无法编译该文档。

我正在使用 Overleaf V2 并出现此错误。

在此处输入图片描述

梅威瑟:

\documentclass{article}
\usepackage{tikz}
\usepackage{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
                {\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left}
                {\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}}
%           \pgfusepath{draw,fill}      

}
\makeatother

\begin{document}
\begin{center}
\begin{tikzpicture}[american]

\ctikzset{tripoles/mos style/arrows}

\draw (0,0) node[pmos,anchor=source] (M1){new pmos}; 

\draw (0,2) node[nmos,anchor=source] (M2){nmos}; 
\end{tikzpicture}
\end{center}
\end{document}

我在使用 TeX Studio 时也遇到了与 TeX Live 相同的问题

答案1

引发错误的命令可能来自旧版本的circuitikz

现在的命令是\pgfcircdeclaretransistor。更改命令名称,它应该可以工作:

% \pgfcircdeclaremos{pmos}{
\pgfcircdeclaretransistor{pmos}{...

在此处输入图片描述

相关内容