我正在使用 circuitikz,我想知道是否可以让一条线穿过一个圆圈,就像有些人表示一些电流传感器一样,如下所示:
这是一个使用 circuitikz 的工作示例
\documentclass[tikz, border = 5pt]{standalone}
\usepackage[oldvoltagedirection]{circuitikz}
\begin{document}
\begin{figure}
\begin{circuitikz} [american voltages]
\draw
(0,0) node[ground] (terra){}
to[V, l=$V_s$] ++(0,2)
to[switch] ++(2,0)
to[full diode,invert,bipoles/diode/width=0.3 ,bipoles/diode/height=0.3] ++(0,-2)
(2,2) to[L] ++(2,0)
to[C] ++(0,-2)
to[short] ++(2,0)
to[R,mirror,invert,l_=$R_{load}$] ++(0,2)
to[short] ++(-2,0)
(0,0) to[short] (6,0)
;
\end{circuitikz}
\end{figure}
\end{document}
答案1
@Schrödinger'scat 回答很好,而且非常易于配置(例如颜色),但请注意,如果您只需要符号,您可以使用(自 0.9.0 起)新的iloop
(部分仪器),如下所示:
\documentclass[border = 5pt]{standalone}
\usepackage[RPvoltages]{circuitikz}
\begin{document}
\begin{circuitikz} [american voltages]
\ctikzset{diodes/scale=0.6}
\draw
(0,0) node[ground] (terra){}
to[V, l=$V_s$] ++(0,2)
to[switch] ++(2,0)
to[full diode,invert] ++(0,-2)
(2,2) to[L] ++(2,0)
to[C] ++(0,-2)
to[short] ++(2,0)
to[R,mirror,invert,l_=$R_{load}$] ++(0,2)
to[iloop, name=myI] ++(-2,0)
(0,0) to[short] (6,0)
;
\draw (myI.i) --++(0,-0.5) node[below]{$i(t)$};
\end{circuitikz}
\end{document}
另外,请注意 是RPoltages
首选oldvoltagedirection
--- 详情请参阅手册。如果您有 0.9.5 或更高版本,使用样式来获得更小的二极管也会简化电路。
PS:只是出于好奇,为什么mirror, invert
是电阻器?
答案2
这是一个这样的箭头。
\documentclass[varwidth, border = 5pt]{standalone}
\usepackage[oldvoltagedirection]{circuitikz}
\usetikzlibrary{arrows.meta}
\pgfkeys{
/pgf/arrow keys/.cd,
main angle/.code={%
\pgfmathparse{#1}%
\expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\def\expandafter\pgfarrowmainangle\expandafter{\pgfmathresult}}
},
offset angle/.code={%
\pgfmathparse{#1}%
\expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\def\expandafter\pgfarrowoffsetangle\expandafter{\pgfmathresult}}
},
aspect/.code={%
\pgfmathparse{#1}%
\expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\def\expandafter\pgfarrowaspect\expandafter{\pgfmathresult}}
},
}%
\def\pgfarrowmainangle{90}%
\def\pgfarrowoffsetangle{20}%
\def\pgfarrowaspect{0.5}%
\pgfdeclarearrow{
name=Sensor,
parameters={\the\pgfarrowlength,\pgfarrowmainangle,\pgfarrowoffsetangle,\pgfarrowaspect},
setup code={
\pgfarrowssettipend{0pt}
\pgfarrowssetlineend{-\pgfarrowlength}
\pgfarrowlinewidth=\pgflinewidth
\pgfarrowssavethe\pgfarrowlength
},
drawing code={
\ifdim\pgfarrowmainangle pt>0pt
\pgfpathmoveto{\pgfpointpolar{\pgfarrowmainangle+\pgfarrowoffsetangle}{\pgfarrowlength and \pgfarrowaspect\pgfarrowlength}}%
\pgfpatharc{\pgfarrowmainangle+\pgfarrowoffsetangle}{\pgfarrowmainangle+360-\pgfarrowoffsetangle}{\pgfarrowlength and \pgfarrowaspect\pgfarrowlength}%
\else
\pgfpathmoveto{\pgfpointpolar{\pgfarrowmainangle-\pgfarrowoffsetangle}{\pgfarrowlength and \pgfarrowaspect\pgfarrowlength}}%
\pgfpatharc{\pgfarrowmainangle-\pgfarrowoffsetangle}{\pgfarrowmainangle-360+\pgfarrowoffsetangle}{\pgfarrowlength and \pgfarrowaspect\pgfarrowlength}%
\fi
\pgfusepathqstroke
},
defaults = { length = 4pt}
}
\begin{document}
\begin{circuitikz}[american voltages]
\draw
(0,0) node[ground] (terra){}
to[V, l=$V_s$] ++(0,2)
to[switch] ++(2,0)
to[full diode,invert,bipoles/diode/width=0.3 ,bipoles/diode/height=0.3] ++(0,-2)
(2,2) to[L] ++(2,0)
to[C] ++(0,-2)
to[short] ++(2,0)
to[R,mirror,invert,l_=$R_{load}$] ++(0,2)
to[short] ++(-2,0)
(0,0) to[short] (6,0)
;
\draw[thick,-Sensor] (5,1) -- (5,2);
\draw[thick,-{Sensor[main angle=-90]}] (1,1) -- (1,0);
\end{circuitikz}
\end{document}
请注意,我不是circuitikz
专家。也就是说,我认为这是有效的 Ti钾Z 回答,但我不知道这是否遵循了的惯例circuitikz
。还请注意,在文档类figure
中使用standalone
是没有意义的(除非有人做了一些额外的事情)。