# CircuiTikZ - change position of voltage label along open draw

TeX - LaTeX Asked by DraUX on May 8, 2021

Is there a way to adjust the appearance of an voltage label between two points? For default the label $U_1$ will be placed midway of the voltage arrow, but I want it to appear at a point realtive to the length of the voltage arrow, for example at quarter way or at 70% way.

usepackage[americaninductors, straightvoltages]{circuitikz}

begin{document}
begin{circuitikz}
draw (0,0) to [open, v^=$U_1$] (2,0);
end{circuitikz}
end{document}


It depends basically on how new is your circuitikz. Since 1.2.1 you can use the coordinates for voltages and do something like that:

documentclass[a4paper,12pt]{article}
usepackage[EFvoltages, americaninductors, straightvoltages]{circuitikz}

begin{document}
begin{circuitikz}
draw
(0,0) to [open, v, name=O1] (2,0);
draw [thin, -Triangle] (O1-Vfrom) -- (O1-Vto) node[above, pos=0.2]{$U_1$};
end{circuitikz}
end{document}


Notice that I added the voltage direction option (please look at the warnings!). I copy here the relevant part of the manual...

Correct answer by Rmano on May 8, 2021

I hope to have understand well. You can shift the label manually using with the command mkern<value>...just this is like an example.

documentclass[a4paper,12pt]{article}
usepackage[americaninductors, straightvoltages]{circuitikz}

begin{document}
begin{circuitikz}
draw (0,0) to [open, v^=$U_1$] (2,0);
draw (0,0) to [open, v^=$mkern30mu U_2$] (2,0);
end{circuitikz}
end{document}


Answered by Sebastiano on May 8, 2021

one solution is an extra node at the right position and replace the voltage label with a protected space like this

documentclass[a4paper,12pt]{article}
usepackage[americaninductors, straightvoltages]{circuitikz}

begin{document}
begin{circuitikz}
draw
(0,0) to [open, v= ] (2,0)
(0.5,0) node[above]{$U_1$};
end{circuitikz}
end{document}


but its not a very smart solution...

Answered by DraUX on May 8, 2021