我有下一个代码:
\begin{center}
\begin{circuitikz}[american,thick]
\ctikzset{bipoles/thickness=2}
\draw (0,0) to [R = $R$,i=$i_f$,v=$v_R$] (4,0);
\draw (4,0) to [empty led,v=$v_{LED}$](8,0);
\draw (8,0) -- (8,-0.5) node[ground]{};
\end{circuitikz}
\end{center}
得出的结果是:
我想要得到的就是下图中用红色表示的内容:
- +5V 标签(黑色)。
- 电压指示器也是黑色的,但与相关元件完全分开。
- 将 LED 颜色填充为红色。
答案1
第一个要求
\documentclass[11pt]{article}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}[american,thick]
\ctikzset{bipoles/thickness=2}
\draw [short,o-](0,0) to [R = $R$,i=$i_f$,v=$v_R$] (4,0);
\draw (4,0) to [empty led,v=$v_{LED}$](8,0);
\draw (8,0) -- (8,-0.5) node[ground]{};
\node[left=1cm] (node name) {+5V};
\end{circuitikz}
\end{document}
第二项要求
\documentclass[11pt]{article}
\usepackage{circuitikz}
\usetikzlibrary{calc, positioning}
\begin{document}
\begin{circuitikz}[american,thick]
\ctikzset{bipoles/thickness=2}
\draw [short,o-](0,0) to [R = $R$,i=$i_f$,v=$v_R$, name=r] (4,0);
\draw (4,0) to [empty led,v=$v_{LED}$](8,0);
\draw (8,0) -- (8,-0.5) node[ground]{};
\node[left=1cm] (node name) {+5V};
\draw[red,rounded corners=0.2cm,-latex, out=260,in=280,looseness=1.2] ($(r.east)+(0.5,0)$) to ($(r.west)+(-0.5,0)$);
\end{circuitikz}
\end{document}
第三项要求
\documentclass[11pt]{article}
\usepackage{circuitikz}
\usetikzlibrary{calc, positioning}
\begin{document}
\begin{circuitikz}[american,thick]
\ctikzset{bipoles/thickness=2}
\draw [short,o-](0,0) to [R = $R$,i=$i_f$,v=$v_R$, name=r] (4,0);
\draw (4,0) to [empty led,v=$v_{LED}$, name=led](8,0);
\draw (8,0) -- (8,-0.5) node[ground]{};
\node[left=1cm] (node name) {+5V};
\draw[red,rounded corners=0.2cm,-latex, out=260,in=280,looseness=1.2] ($(r.east)+(0.5,0)$) to ($(r.west)+(-0.5,0)$);
\draw[red,rounded corners=0.2cm,-latex, out=260,in=280,looseness=2.3] ($(led.east)+(0.5,0)$) to ($(led.west)+(-0.5,0)$);
\end{circuitikz}
\end{document}
第四项要求
\documentclass[11pt]{article}
\usepackage{circuitikz}
\usetikzlibrary{calc, positioning}
\begin{document}
\begin{circuitikz}[american,thick]
\ctikzset{bipoles/thickness=2}
\draw [short,o-](0,0) to [R = $R$,i=$i_f$,v=$v_R$, name=r] (4,0);
\draw (4,0) to [empty led,v=$v_{LED}$, name=led, fill=red](8,0);
\draw (8,0) -- (8,-0.5) node[ground]{};
\node[left=1cm] (node name) {+5V};
\draw[red,rounded corners=0.2cm,-latex, out=260,in=280,looseness=1.2]
($(r.east)+(0.5,0)$) to ($(r.west)+(-0.5,0)$);
\draw[red,rounded corners=0.2cm,-latex, out=260,in=280,looseness=2.3]
($(led.east)+(0.5,0)$) to ($(led.west)+(-0.5,0)$);
\end{circuitikz}
\end{document}
答案2
如果你使用正确的选项,这是附带的基本输出circuitikz
:
\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\begin{document}
\begin{circuitikz}[american,thick]
\ctikzset{bipoles/thickness=2, voltage=european}
\draw (0,0) node[left]{\SI[retain-explicit-plus]{+5}{\volt}}
to [R = $R$,i=$i_f$,v=$v_R$, o-] (4,0);
\draw (4,0) to [empty led,fill=red, v=$v_{LED}$](8,0);
\draw (8,0) -- (8,-0.5) node[ground]{};
\end{circuitikz}
\end{document}
您可以使用几个参数来改变箭头的外观(参见手册),或者,如果您确实想要一个非常不同的外观,可以使用高级电压(它们是实验性的,但或多或少是有效的)。
要消除电压,您只需使用参数bump b
(手册第 142 页)。
\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\begin{document}
\begin{circuitikz}[american,thick]
\ctikzset{bipoles/thickness=2, voltage=european}
\draw (0,0) node[left]{\SI[retain-explicit-plus]{+5}{\volt}}
to [R = $R$,i=$i_f$,v=$v_R$, voltage/bump b=3.5, o-] (4,0);
\draw (4,0) to [empty led,fill=red, v=$v_{LED}$, voltage/bump b=2.5](8,0);
\draw (8,0) -- (8,-0.5) node[ground]{};
\end{circuitikz}
\end{document}
如果你真的想要电压在下面箭头、不同的颜色等,您必须对绘制箭头负全部责任(参见手册第 153 页,“高级电压...”)
\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\begin{document}
\begin{circuitikz}[american,thick]
\ctikzset{bipoles/thickness=2, voltage=european}
\draw (0,0) node[left]{\SI[retain-explicit-plus]{+5}{\volt}}
to [R = $R$,i=$i_f$,l_=$v_R$, v, name=myr, o-] (4,0);
\draw (4,0) to [empty led,fill=red, l_=$v_{LED}$, v, name=myled](8,0);
\draw (8,0) -- (8,-0.5) node[ground]{};
\draw [-Triangle, red] ([yshift=-0.5cm]myled-Vfrom) to[out=-120, in=-60] ([yshift=-0.5cm]myled-Vto);
\draw [-Triangle, red] ([yshift=-0.5cm]myr-Vfrom) to[out=-120, in=-60] ([yshift=-0.5cm]myr-Vto);
\end{circuitikz}
\end{document}