为什么我使用其他双极子时会出现错误Package pgf Error: Unknown shape ``R''.
(或),但我可以毫无问题地使用其他符号?如何使用双极子\pgfnode
?
\documentclass{standalone}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}
\begin{tikzpicture}
% Draw transistor.
\pgftransformshift{\pgfpoint{0cm}{0cm}}
% This works.
\pgfnode{nfet}{center}{}{}{\pgfusepath{draw}}
% Draw resistor.
\pgftransformshift{\pgfpoint{2cm}{0cm}}
% This doesn't work. Why?
\pgfnode{R}{center}{}{}{\pgfusepath{draw}}
\end{tikzpicture}
\end{document}
答案1
这是因为双极子组件名称与相应的 pgf 形状名称不同。Circuitikz 手册(第 6 页,脚注)说:
对于使用双极子作为节点,节点的名称为
<component name>shape
因此对于电阻器,请使用resistorshape
而不是R
。请看其他几个例子:
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}
\begin{tikzpicture}
% Draw transistor.
\pgftransformshift{\pgfpoint{0cm}{0cm}}
% This works.
\pgfnode{nfet}{center}{}{}{\pgfusepath{draw}}
% Draw resistor.
\pgftransformshift{\pgfpoint{2cm}{0cm}}
\pgfnode{resistorshape}{center}{}{}{\pgfusepath{draw}}
\pgftransformshift{\pgfpoint{2cm}{0cm}}
\pgfnode{capacitorshape}{center}{}{}{\pgfusepath{draw}}
\pgftransformshift{\pgfpoint{2cm}{0cm}}
\pgfnode{cuteinductorshape}{center}{}{}{\pgfusepath{draw}}
\pgftransformshift{\pgfpoint{2cm}{0cm}}
\pgfnode{americaninductorshape}{center}{}{}{\pgfusepath{draw}}
\pgftransformshift{\pgfpoint{2cm}{0cm}}
\pgfnode{genericshape}{center}{}{}{\pgfusepath{draw}}
\pgftransformshift{\pgfpoint{-8cm}{-2cm}}
\pgfnode{emptydiodeshape}{center}{}{}{\pgfusepath{draw}}
\pgftransformshift{\pgfpoint{2cm}{0cm}}
\pgfnode{emptyvarcapshape}{center}{}{}{\pgfusepath{draw}}
\pgftransformshift{\pgfpoint{2cm}{0cm}}
\pgfnode{cspstshape}{center}{}{}{\pgfusepath{draw}}
\pgftransformshift{\pgfpoint{2cm}{0cm}}
\pgfnode{batteryshape}{center}{}{}{\pgfusepath{draw}}
\pgftransformshift{\pgfpoint{2cm}{0cm}}
\pgfnode{ammetershape}{center}{}{}{\pgfusepath{draw}}
\end{tikzpicture}
\end{document}
PS:相同形状可以有多个名称,但形状名称相同。因此找到正确的名称可能有点困难。尤其是当它没有正确记录时(circuitikz 手册的索引是最好的选择)。