这是代码。
\documentclass[12pt,letterpaper]{article}
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}
\usepackage[siunitx]{circuitikz} % circuit package and include electrical units in our labels
\begin{document}
\begin{center}
\tikzstyle{arrow}=[draw, -latex]
\begin{circuitikz} [american voltages, american currents] \draw
(5,0) to [capacitor, a = $C_1$] (5,3) --
(2,3) to [inductor, a^ = L, mirror] (-1,3) to [capacitor, a^ = $C_2$, name=C2] (-1, 1.8)
to [V, l = $\frac{V_{\pi}} {s}$]
(-1,0) -- (1,0) -- (3,0) -- (5,0)
(3.5,3) to [R, l = R] (3.5,0)
;
\end{circuitikz}
\end{center}
\end{document}
这是我从这段代码中获得的。
但是,我想要下面这样的东西。我想在电路中添加箭头并改变电压的方向。
答案1
对于生成器,只需添加invert
其选项。
对于电流,您可以使用添加电流箭头及其标签来代替(-1,0) -- (1,0)
底部导线中的 普通线条...(-1,0) to[short, i=$I(s)$] (1,0)
我在下面的代码中添加了更多注释。
\documentclass[12pt,letterpaper]{article}
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}
\usepackage[siunitx]{circuitikz}
\begin{document}
\begin{center}
% notice that this style (which is in the old, deprecated format)
% will NOT affect circuitikz, where arrows are shapes (mostly)
% \tikzstyle{arrow}=[draw, -latex]
% the correct (modern) way is
\tikzset{arrow/.style={draw, -latex}}
%
\begin{circuitikz} [american voltages, american currents] \draw
(5,0) to [capacitor, a = $C_1$] (5,3) --
(2,3) to [inductor, a^ = L, mirror] (-1,3) to [capacitor, a^ = $C_2$, name=C2] (-1, 1.8)
to [V, l = $\frac{V_{\pi}} {s}$, invert] % CHANGED: use "invert"
% CHANGED: use to[short...] to add currents (and flows, poles, etc.)
(-1,0) to[short, i=$I(s)$] (3,0) -- (5,0)
(3.5,3) to [R, l = R] (3.5,0)
;
\end{circuitikz}
\end{center}
\end{document}
如果你想改变当前方向,你可以使用
to[short, i<=$I(s)$]
>
或者使用、<
、_
、四个组合^
来选择方向和标签位置,如手册中“电流:”部分所述
在当前的情况下,组件为short
,箭头位于路径的中心,因此前四个选项和后四个选项基本等效。
答案2
尝试一下这个代码。
\documentclass[12pt,letterpaper]{article}
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}
\usepackage[siunitx]{circuitikz} % circuit package and include electrical units in our labels
\begin{document}
\begin{center}
\tikzstyle{arrow}=[draw, -latex]
\begin{circuitikz} [american voltages, american currents]
\draw(5,0) to [capacitor, a = $C_1$] (5,3) -- (2,3) to [inductor, a^ = L, mirror] (-1,3) to [capacitor, a^ = $C_2$, name=C2] (-1, 1.8)
to [V, invert, l = $\frac{V_{\pi}} {s}$]
(-1,0) -- (1,0) -- (3,0) -- (5,0)
(3.5,3) to [R, l = R] (3.5,0) ;
\draw[->] (-1,0)--(0.5,0); % add an arrow inline
\end{circuitikz}
\end{center}
\end{document}