我该如何使用 Circuitikz 写出标签 R1,其下方的电阻为 560 欧姆?理想情况下,我希望在电阻标签中有一个换行符。
\begin{circuitikz}
%\draw[style=help lines] (-8,-8) grid (8,8);
\draw
(0,0) node[npn,rotate=90] (darl) {} node[above] {$Q1$}
(0,-3) node[npn,xscale=-1] (npn) {} node[left] {$Q2$}
(darl.B) to[short,-*,i<^=\SI{37.2}{\micro\ampere}] ++(0,-0.65) node (base) {}
to[short,i>^=\SI{5.67}{\milli\ampere}] (npn.C)
(darl.E) to[short,-*,i=\SI{518}{\milli\ampere}] ++(1.23,0) node (zen) {}
to[short,-*] ++(2,0) node (div) {}
to[short,-o] ++(1.5,0) node (out1) {}
to[short] ++(1,0)
to[vR,i>^=\SI{500}{\milli\ampere},l=$R_L$] ++(0,-6)
to[short,-o] ++(-1,0) node (out2) {}
to[short,-*] ++(-1.5,0)
to[short,-*] ++(-4,0)
to[short] ++(-3.5,0)
to[V,l=\SI{18}{\volt}] ++(0,6)
(zen) to[R,l=\SI{1.2}{\kilo\ohm},i>^=\SI{5.41}{\milli\ampere}] ++(0,-3)
|- (npn.E)
(0,-6) to[zD,-*,v_>=\SI{6.2}{\volt},i^<=\SI{12.7}{\milli\ampere}] (npn.E)
(div) to[R,-*,l=$\SI{470}{\ohm}$,i>^=\SI{12.3}{\milli\ampere}] ++(0,-3) node (fb) {}
to[R,l=$\SI{560}{\ohm}$,v_=\SI{6.90}{\volt}] ++(0,-3)
(npn.B) to[short] (fb)
(darl.C) to[short,-*] ++(-1,0) node (Rbe) {}
to[short] ++(-0.235,0)
to[short] ++(-1.5,0)
(Rbe) to[short,i_=\SI{5.71}{\milli\ampere}] ++(0,-1.5)
to[R,l_=\SI{680}{\ohm}] ++(1.76,0)
(6.5,0) to[short,*-o] ++(1,0) node[right] {$\SI{12.7}{\volt}$}
;
\end{circuitikz}
答案1
你可以自己给一些东西贴上标签:
(div) to[R,-*,l=$\SI{470}{\ohm}$,i>^=\SI{12.3}{\milli\ampere}] ++(0,-3) node (fb) {}
to[R,v_=\SI{6.90}{\volt}] node[midway,right=1.3em,align=left] {R2\\$\SI{560}{\ohm}$} ++(0,-3)
完整代码:
\documentclass{article}
\usepackage{circuitikz}
\usepackage{siunitx}
\begin{document}
\begin{circuitikz}
%\draw[style=help lines] (-8,-8) grid (8,8);
\draw
(0,0) node[npn,rotate=90] (darl) {} node[above] {$Q1$}
(0,-3) node[npn,xscale=-1] (npn) {} node[left] {$Q2$}
(darl.B) to[short,-*,i<^=\SI{37.2}{\micro\ampere}] ++(0,-0.65) node (base) {}
to[short,i>^=\SI{5.67}{\milli\ampere}] (npn.C)
(darl.E) to[short,-*,i=\SI{518}{\milli\ampere}] ++(1.23,0) node (zen) {}
to[short,-*] ++(2,0) node (div) {}
to[short,-o] ++(1.5,0) node (out1) {}
to[short] ++(1,0)
to[vR,i>^=\SI{500}{\milli\ampere},l=$R_L$] ++(0,-6)
to[short,-o] ++(-1,0) node (out2) {}
to[short,-*] ++(-1.5,0)
to[short,-*] ++(-4,0)
to[short] ++(-3.5,0)
to[V,l=\SI{18}{\volt}] ++(0,6)
(zen) to[R,l=\SI{1.2}{\kilo\ohm},i>^=\SI{5.41}{\milli\ampere}] ++(0,-3)
|- (npn.E)
(0,-6) to[zD,-*,v_>=\SI{6.2}{\volt},i^<=\SI{12.7}{\milli\ampere}] (npn.E)
(div) to[R,-*,l=$\SI{470}{\ohm}$,i>^=\SI{12.3}{\milli\ampere}] ++(0,-3) node (fb) {}
to[R,v_=\SI{6.90}{\volt}] node[midway,right=1.3em,align=left] {R2\\$\SI{560}{\ohm}$} ++(0,-3)
(npn.B) to[short] (fb)
(darl.C) to[short,-*] ++(-1,0) node (Rbe) {}
to[short] ++(-0.235,0)
to[short] ++(-1.5,0)
(Rbe) to[short,i_=\SI{5.71}{\milli\ampere}] ++(0,-1.5)
to[R,l_=\SI{680}{\ohm}] ++(1.76,0)
(6.5,0) to[short,*-o] ++(1,0) node[right] {$\SI{12.7}{\volt}$}
;
\end{circuitikz}
\end{document}
答案2
这里使用带有标签选项的节点xshift=xx
yshift=xx
来添加标签 R1。此外,560 欧姆也被包裹起来raisebox
上下移动以进行对齐。
为了节省空间,我只发布需要更改/添加的第 28 行。(其余部分保持不变)
(div) to[R,-*,l=$\SI{470}{\ohm}$,i>^=\SI{12.3}{\milli\ampere}] ++(0,-3) node (fb) {} to[R,l=\raisebox{-1cm}{$\SI{560}{\ohm}$},v_=\SI{6.90}{\volt}]
node[label= {[xshift=1cm,yshift=1ex]above:R1}]{} ++(0,-3)
这就是结果
答案3
和
\makeatletter
\expandafter\let\csname pgfk@\circuitikzbasekey/@loriginal/.@cmd\expandafter\endcsname\csname pgfk@\circuitikzbasekey/l/.@cmd\endcsname
\ctikzset{l/.code={%
\pgfutil@ifnextchar[\pgf@circ@handleOPT{\pgf@circ@handleOPT[]}#1\pgf@stop}}
\def\pgf@circ@handleOPT[#1]#2\pgf@stop{%
\def\pgf@circ@options{#1}%
\ctikzset{@loriginal={#2}}}
\usepackage{etoolbox}
\patchcmd\pgf@circ@drawreglabel{]}{,style/.expand once=\pgf@circ@options]}{}{}
\makeatother
在序言中,你可以这样做
to[R,
l={[align=left]$R_1$\\$\SI{560}{\ohm}$},
v_=\SI{6.90}{\volt}
] ++(0,-3)
对每个节点分别进行。
当然,你可以定义一些类似的东西al/.style={align=left}
来使内容更简短:
l={[al]$R_1$\\\$SI{…}{…}$}
或者甚至al/.style 2 args={l={[align=left]#1\\#2}}
可以用作
al={$R_1$}{$\SI{…}{…}$}
在to
路径运算符选项中。