[Tex/LaTex] Spacing circuit element labels from their elements with CircuiTikz

circuitikzlabelstikz-pgf

I want to draw a resistor with a resistance value showing and a voltage label showing as well. This is content-wise an MWE of everything I want:

\documentclass{article}
\usepackage[siunitx]{circuitikz}

\begin{document}
\begin{circuitikz}[american]

    \draw (2,0) to[R=90<\ohm>, v_>=$v_g$] (2,2) ;

\end{circuitikz}
\end{document}

but when the resistor is vertical, the v_g variable is extremely close to the resistor, with the - symbol touching the resistor's terminal line, the + symbol even crossing the terminal line, and the v_g down in the zig zags of the resistor. I just started using circuitikz today and am trying to search through the documentation, but does anyone know how to space away the v_>=$variable_name_here$ part?

Best Answer

Not sure if there is a better way, but you can use label/align=rotate which produces good results, or add manual spacing (but this does apply to the polarity signs) as shown in the example below.

Here is a comparison of these two options:

enter image description here

\documentclass{article}
\usepackage[siunitx]{circuitikz}

\begin{document}

\begin{circuitikz}[american]
    \draw (0,0) to[R=90<\ohm>, v_>=$v_g$] (0,2)
        node [above] {\tiny\verb|default|};
    \draw (2,0) to[R=90<\ohm>, v_>=$v_g$,label/align=rotate] (2,2)
        node [above] {\tiny\verb|label/align=rotate|};
    \draw (4,0) to[R=90<\ohm>, v_>=$\quad v_g$] (4,2) 
        node [above] {\tiny\verb|\quad|};
\end{circuitikz}
\end{document}