4

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 3

3

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

3

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

3
  • 1
    thanks, but I'm rather searching for an option to define a position relative to the length of the arrow. Like at the beginning or at quarter way.
    – DraUX
    Aug 27, 2020 at 16:12
  • @DraUX Hence your question is relative to the lenght of an arrow (voltage)? If you prefer I delete my answer or later I will read the recent manual of circuitikz.
    – Sebastiano
    Aug 27, 2020 at 16:16
  • I tried to specify my question. I hope it makes clear, for what I'm searching.
    – DraUX
    Aug 27, 2020 at 16:26
1

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...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .