我正在做电路作业,并尝试绘制图表。
在图表中,我尝试绘制一条中间带有箭头的曲线,并带有标签。这是我所得到的:
\begin{center}
\begin{circuitikz}
\draw (0,3) to[short,i>=$b$, o-o] (3,3) to[short,i>=$d$, o-o] (6,3);
\draw (0,3) to[short,i>=$a$, o-o] (3,0);
\draw (3,3) to[short,i>=$c$, o-o] (3,0);
\draw (6,3) to[short,i>=$e$, o-o] (3,0);
\draw (6,3) to[short, i>= $f$, o-o] [out=-90, in=0] (3, 0); \\Error
\end{circuitikz}
\end{center}
我意识到图形的曲线边缘穿过了节点,而不是停在节点上。有人能帮忙指出错误并展示绘制曲线分支的正确方法吗?或者展示提供完全相同结果的circuitikz
代码吗?tikzpicture
答案1
to
的 -path 处理程序不circuitikz
处理弯曲的电线。虽然我明白有时它们会有所帮助,但它们会增加太多的复杂性(至少在中间有组件的路径的情况下)。对于电线,Ti钾Z 拥有所需的工具。这是一个例子:
\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[siunitx, RPvoltages]{circuitikz}
% get the circuitikz arrow size, define a tip https://tex.stackexchange.com/a/549354/38080
\makeatletter
\newdimen\ctikzAL\newdimen\ctikzAW
\pgfmathsetlength{\ctikzAL}{ 1.7 * \pgf@circ@Rlen / \ctikzvalof{current arrow scale} + 2*\pgflinewidth}
\pgfmathsetlength{\ctikzAW}{ 1.6 * \pgf@circ@Rlen / \ctikzvalof{current arrow scale} + 2*\pgflinewidth}
\tikzset{c>/.tip={Triangle[length=\the\ctikzAL, width=\the\ctikzAW]}}
\makeatother
% See https://tex.stackexchange.com/a/39282/38080
\usetikzlibrary{decorations.markings}
\tikzset{->-/.style={decoration={
markings,
mark=at position 0.5 with {\arrow{c>}}},postaction={decorate}}}
\begin{document}
\begin{tikzpicture}[]
\draw (0,3) to[short,i>=$b$, o-o] (3,3) to[short,i>=$d$, o-o] (6,3);
\draw (0,3) to[short,i>=$a$, o-o] (3,0);
\draw (3,3) to[short,i>=$c$, o-o] (3,0);
\draw (6,3) to[short,i>=$e$, o-o] (3,0);
% see https://tikz.dev/tutorial-nodes#sec-3.11
\draw[->-] (6,3) to[out=-90, in=0] node[auto]{$f$} (3, 0);
\end{tikzpicture}
\end{document}
参考:Circuitikz 箭头,Tikz:箭头位于中心,https://tikz.dev/tutorial-nodes#sec-3.11
如您所见,最后的电线从“杆”的中心开始,如circuitikz
手册第 6.1 节中所述。在这种情况下,您可以通过简单地在其余部分之前绘制弯曲的东西并依靠杆填充来解决这个问题。
\begin{tikzpicture}[]
% see https://tikz.dev/tutorial-nodes#sec-3.11
\draw[->-] (6,3) to[out=-90, in=0] node[auto]{$f$} (3, 0);
\draw (0,3) to[short,i>=$b$, o-o] (3,3) to[short,i>=$d$, o-o] (6,3);
\draw (0,3) to[short,i>=$a$, o-o] (3,0);
\draw (3,3) to[short,i>=$c$, o-o] (3,0);
\draw (6,3) to[short,i>=$e$, o-o] (3,0);
\end{tikzpicture}