I'm trying to modify the pmos definition in circuitikz as per this answer but I cannot get the document to compile.

I am using Overleaf V2 and I get this error.

enter image description here

MWE:

\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}

I'm also having the same issue with TeX Live using TeX Studio

up vote 5 down vote accepted

The command that is throwing the error is probably from an older version of circuitikz.

Nowadays the command is \pgfcircdeclaretransistor. Change the command name and it should work:

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

enter image description here

  • Thanks for the answer! – jagjordi Dec 6 at 13:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.