作为我的电气工程部门的一部分,我想展示产生或耗散能量的各种元素。
我的一个讲座上有这张图片,我想知道是否使用 Ti钾Z 是实现此图像的唯一方法。
我很乐意修改输出,如果 CircuiTi钾Z 已预先定义这些形状。
我使用 LaTeX 的尝试:
\documentclass{standalone}
\usepackage{circuitikz}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\begin{circuitikz}
\draw (0, 0) -- (0.5, 0) to[generic] (0.5, 2) -- (0, 2);
% Current direction arrows
\draw[latex-] (-0.5, 2) node[anchor = east] {$i$} -- (-.1, 2);
\draw[latex-] (-0.1, 0) -- (-.5, 0);
% Charge signs
\draw (0.5, 0) node[anchor = west] {$-$};
\draw (0.5, 2) node[anchor = west] {$+$};
% Power snake line
\draw[<-, decorate, decoration = {snake, amplitude = .4mm, segment length = 2mm}]
(0.71, 1) -- (1.21, 1.5) node[anchor = west] {$p=-vi$};
\end{circuitikz}
\end{document}
答案1
to[out=<angle>,in=<another angle>]
如果您希望箭头像图片中的那样,那么可以使用语法:
\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0, 0) -- (0.5, 0) to[generic] (0.5, 2) -- (0, 2);
% Current direction arrows
\draw[latex-] (-0.5, 2) node[anchor = east] {$i$} -- (-.1, 2);
\draw[latex-] (-0.1, 0) -- (-.5, 0);
% Charge signs
\draw (0.5, 0) node[anchor = west] {$-$};
\draw (0.5, 2) node[anchor = west] {$+$};
% Power snake line
\draw[<-] (0.72, 1) to[out=0,in=180] (1.21, 1.5) node[anchor = west] {$p=-vi$};
\end{circuitikz}
\end{document}
答案2
circuitikz
基本上是 Ti 的扩展钾Z,所以我认为没有必要重新做已经存在的东西。你可以使用高级锚来获得某种力量流(见https://texdoc.org/serve/circuitikz/0#subsection.5.8),但在这种情况下 Ti钾Z 为您提供很好的服务。
我建议定义一种样式,然后使用相对坐标来定位你的动力蛇(这样如果你移动组件,你就不必改变任何东西:)
\documentclass{standalone}
\usepackage{circuitikz}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{power snake/.style=
{Latex-, decorate, decoration={snake,
amplitude=.4mm,segment length=2mm,post length=.2mm, pre length=2mm}
}
}
\begin{document}
\begin{circuitikz}
% name the component
\draw (0, 0) -- (0.5, 0) to[generic, name=comp] (0.5, 2) -- (0, 2);
% Current direction arrows
\draw[latex-] (-0.5, 2) node[anchor = east] {$i$} -- (-.1, 2);
\draw[latex-] (-0.1, 0) -- (-.5, 0);
% Charge signs
\draw (0.5, 0) node[anchor = west] {$-$};
\draw (0.5, 2) node[anchor = west] {$+$};
% Power snake line (use the component anchor, remember that anchors are
% defined for the horizontal component going left to right!
\draw[power snake] (comp.south) -- ++(.6,.5) node[anchor = west] {$p=-vi$};
\end{circuitikz}
\end{document}