我试图获取两个节点之间的电压标签,但该电压与任何电路元件均无关联。这是我目前能找到的最好的方法:
\documentclass[tikz,border=5pt]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz} [american voltages, baseline=(current bounding box.center)]
\ctikzset { label/align = straight }
\draw (0,0)
% fake resistor, using for voltage label only
(3.5, 1.8) to [R, v=$v_1$, color=white] (3.5,0.2)
(1.5,2) to[short, -o] (1.5,2)
(1.5,2) to[short,i=$i$, -o] (5,2)
to[short] (4.5,2)
(1.5,0) to[short, -o] (1.5,0)
(1.5,0) to[short, -o] (5,0)
to[short] (4.5,0);
\node[draw,minimum width=2cm,minimum height=2.4cm,anchor=south west] at (4.5,-0.2){B};
\node[draw,minimum width=2cm,minimum height=2.4cm,anchor=south west] at (0, -0.2){A};
\end{circuitikz}
\end{document}
这里,我创建了一个电阻器,并尝试通过将颜色设置为白色(背景为白色)使其不可见。但电阻器端子仍然可见。
如何让端子不可见?更好的是,有没有办法在不创建虚拟电路元件的情况下做到这一点?
答案1
您可以使用
(3.5, 1.8) to [open,v=$v_1$] (3.5,0.2)
绘制两点之间的电压。
\documentclass[tikz,border=5pt]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz} [american voltages, baseline=(current bounding box.center)]
\ctikzset { label/align = straight }
\draw (0,0)
% fake resistor, using for voltage label only
(3.5, 1.8) to [open,v=$v_1$] (3.5,0.2)
(1.5,2) to[short, -o] (1.5,2)
(1.5,2) to[short,i=$i$, -o] (5,2)
to[short] (4.5,2)
(1.5,0) to[short, -o] (1.5,0)
(1.5,0) to[short, -o] (5,0)
to[short] (4.5,0);
\node[draw,minimum width=2cm,minimum height=2.4cm,anchor=south west] at (4.5,-0.2){B};
\node[draw,minimum width=2cm,minimum height=2.4cm,anchor=south west] at (0, -0.2){A};
\end{circuitikz}
\end{document}