使用 circuitikz 时出错,“缺少数字,视为零”

使用 circuitikz 时出错,“缺少数字,视为零”

我有这个代码:

 \usepackage{pgfplots}
 \usepackage{tikz}
 \pgfplotsset{compat=newest} % Allows to place the legend below plot
 \usepgfplotslibrary{units} % Allows to enter the units nicely
 \usepackage{dblfloatfix}
 \usepackage{fixltx2e}
 \usepackage{commath}

 \usepackage[siunitx]{circuitikz}

 \begin{document}

 \begin{circuitikz}[scale=1] \draw [dashed]
        (0,4) node[above]{\Large{e}}
        (2,1.5) node[right]{\Large{q}}
        to[short] (0,0) node[below]{\Large{f}}
        to[short] (-2,1.5) node[left]{\Large{p}}
        to[short] (0,4)
;
\draw

(0,4)       to[short, i={$ $}] (1.1464,3.5536) 
(1.5,3.2)   circle[radius=0.5cm] node{\LARGE{G}}
(1.8536,2.8536) to[short, i={1}] (2,1.1)
(0,4)       to[short, i_<={$ $}] (-0.75,2.5) 
(-0.75,2)   circle[radius=0.5cm] node{\LARGE{R}}
(-0.75,1.5) to[short, i_<={$ $}] (0,0)
;
\draw [dashed]
(-2,1.5) to (-1,1.5)
(-0.5,1.5) to (0.5,1.5)
(1,1.5) to (2,1.5)


;
\end{circuitikz}
\caption{CODASA}
\label{f_3}
\end{figure}

\end{document}

如果我将此行中的数字更改(1.8536,2.8536) to[short, i={1}] (2,1.1)为,...(2,1.2)它会出现undefined control sequencemissing number...错误。

更新:如果我不使用,错误就会消失i={1}(1.8536,2.8536) to[short] (2,1.1) to ...(2,1.2)但是我需要画箭头。

答案1

那么,如何报告错误呢?

\documentclass{standalone}
 \usepackage{tikz}
 \usepackage[siunitx]{circuitikz}
 \usepackage{pgfplots}
 \pgfplotsset{compat=newest} % Allows to place the legend below plot
 \usepgfplotslibrary{units} % Allows to enter the units nicely
 \usepackage{dblfloatfix}
 \usepackage{fixltx2e}
 \usepackage{commath}

\makeatletter
\def\pgf@circ@drawcurrent{
    \pgfextra{
        \edef\pgf@circ@ffffff{\pgf@circ@direction}
        \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@ffffff\pgf@nil}

        \ifnum\pgfcircmathresult >4 \ifnum\pgfcircmathresult <86
            \ifpgf@circuit@bipole@current@below
                \def\pgf@circ@dir{north west} \else \def\pgf@circ@dir{south east}
            \fi
        \fi\fi
        \ifnum\pgfcircmathresult >85 \ifnum\pgfcircmathresult <95
            \ifpgf@circuit@bipole@current@below
                \def\pgf@circ@dir{west} \else \def\pgf@circ@dir{east} 
            \fi
        \fi\fi
        \ifnum\pgfcircmathresult >94 \ifnum\pgfcircmathresult <176
            \ifpgf@circuit@bipole@current@below
                 \def\pgf@circ@dir{south west}\else \def\pgf@circ@dir{north east}
            \fi
        \fi\fi
        \ifnum\pgfcircmathresult >175 \ifnum\pgfcircmathresult <185
            \ifpgf@circuit@bipole@current@below
                  \def\pgf@circ@dir{south}\else\def\pgf@circ@dir{north}
            \fi
        \fi\fi
        \ifnum\pgfcircmathresult >184 \ifnum\pgfcircmathresult <266
            \ifpgf@circuit@bipole@current@below
                 \def\pgf@circ@dir{south east}\else\def\pgf@circ@dir{north west}
            \fi
        \fi\fi
        \ifnum\pgfcircmathresult >265 \ifnum\pgfcircmathresult <275
            \ifpgf@circuit@bipole@current@below
                 \def\pgf@circ@dir{east}\else \def\pgf@circ@dir{west}
            \fi
        \fi\fi
        \ifnum\pgfcircmathresult >274 \ifnum\pgfcircmathresult <356
            \ifpgf@circuit@bipole@current@below
                  \def\pgf@circ@dir{north east}\else\def\pgf@circ@dir{south west}
            \fi
        \fi\fi
        \ifnum\pgfcircmathresult <5
            \ifpgf@circuit@bipole@current@below
                 \def\pgf@circ@dir{north}\else\def\pgf@circ@dir{south} 
            \fi
        \fi
        \ifnum\pgfcircmathresult >355
            \ifpgf@circuit@bipole@current@below
                 \def\pgf@circ@dir{north}\else\def\pgf@circ@dir{south} 
            \fi
        \fi

        \ifpgf@circuit@bipole@current@below
            \def\pgf@circ@bipole@current@label@where{-90}
        \else
            \def\pgf@circ@bipole@current@label@where{+90}
        \fi
    }


        \pgfextra{  \def\pgf@temp{short} \edef\pgf@circ@temp{\ctikzvalof{bipole/kind}} }

        \ifx\pgf@circ@temp\pgf@temp % caso di corrente (centrata) su un corto
            \ifpgf@circuit@bipole@current@backward
                { (\tikztotarget) -- 
                    node [currarrow, pos=\ctikzvalof{current/distance}, sloped,  allow upside down] (Iarrow) {} 
                  (\tikztostart)  }
            \else
                { (\tikztostart) -- 
                    node [currarrow, pos=\ctikzvalof{current/distance}, sloped,  allow upside down] (Iarrow) {} 
                  (\tikztotarget)  }
            \fi

        \else % altri bipoli - e quindi tra nodo e target

            \ifpgf@circuit@bipole@iscurrent
                \ifpgf@circuit@europeancurrent
                    \pgf@circ@drawnormalcurrent
                \else 
                \fi
            \else
                \pgf@circ@drawnormalcurrent
            \fi
        \fi

    \ifpgf@circuit@bipole@iscurrent
         node [anchor=\pgf@circ@dir] at (\ctikzvalof{bipole/name}.\pgf@circ@bipole@current@label@where) 
            { \pgf@circ@finallabel{current/} }
    \else
        (Iarrow.\pgf@circ@bipole@current@label@where) node [anchor=\pgf@circ@dir]   
            { \pgf@circ@finallabel{current/} } 
    \fi

}
\makeatother

 \begin{document}

 \begin{circuitikz}[scale=1] \draw [dashed]
        (0,4) node[above]{\Large{e}}
        (2,1.5) node[right] (Q) {\Large{q}}
        to[short] (0,0) node[below]{\Large{f}}
        to[short] (-2,1.5) node[left]{\Large{p}}
        to[short] (0,4)
;
\draw

(0,4)       to[short, i={$ $}] (1.1464,3.5536) 
(1.5,3.2)   circle[radius=0.5cm] node{\LARGE{G}}
(1.8536,2.8536) to[short, i={$1$}] (2,1.2)
(0,4)       to[short, i_<={$ $}] (-0.75,2.5) 
(-0.75,2)   circle[radius=0.5cm] node{\LARGE{R}}
(-0.75,1.5) to[short, i_<={$ $}] (0,0)
;
\draw [dashed]
(-2,1.5) to (-1,1.5)
(-0.5,1.5) to (0.5,1.5)
(1,1.5) to (2,1.5)


;
\end{circuitikz}

\end{document}

相关内容