[Tex/LaTex] Circuitikz voltage label independant of element

circuitikz

I am trying get label a voltage between two nodes, but the voltage is not associated with any circuit element. Here's the best I have now:

\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}

Here, I am creating a resistor and trying to make it invisible by setting the color to white (with a white background). The resistor terminals are still visible though.

How can I make the terminals invisible? Better yet, is there a way to do this without creating a dummy circuit element?

Best Answer

You can use

(3.5, 1.8) to [open,v=$v_1$] (3.5,0.2)

to draw the voltage between two points.

\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}

enter image description here