TransWikia.com

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} 

enter image description here

3 Answers

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}

Example image

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

Excerpt of 1.2.3 manual of circuitikz

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} 

enter image description here

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} 

enter image description here

but its not a very smart solution...

Answered by DraUX on May 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP