2

I am using Circuitikz to draw some diagrams involving American batteries (battery1). By default, it includes the polarity, but it places the label partially overlapping it. (See the top image in the diagram below.) I would like to move the 50 V label to below the battery. When I try to do this using either l_ or a, it does move the 50 V label, but also removes the + and - indicating the battery polarity (see the second and third diagrams below). I'd like to move the label but keep the polarity. How can I do this?

The code below shows what I have tried:

    \documentclass[border=3pt]{standalone}
    \usepackage{tikz}
    \usepackage[americanvoltages,fulldiodes,siunitx]{circuitikz}
    \begin{document}
    \begin{circuitikz}
    \draw  (0,0) to [battery1=$50 \, \mathrm{V}$] (3,0); % Polarity, but label above
    \draw  (0,-2) to [battery1,a=$50 \, \mathrm{V}$] (3,-2); % Label below, no polarity
    \draw  (0,-4) to [battery1,l_=$50 \, \mathrm{V}$] (3,-4); % Label below, no polarity
    \end{circuitikz}
    \end{document}

what I'm getting

1 Answer 1

4

Use a "blank" voltage and a label (also fixed warnings and used siunitx correctly):

\documentclass[border=3pt]{standalone}
\usepackage[americanvoltages,fulldiodes,siunitx, nooldvoltagedirection]{circuitikz}
\begin{document}
    \begin{circuitikz}
        \draw  (0,-4) to [battery1,v_={~}, l^=\SI{50}{V}] (3,-4); % Label below, no polarity
    \end{circuitikz}
\end{document}

enter image description here

You can use v_, v^, l_, l^ for the above/below position.

The overlap was at least partially fixed in one of the recent versions of circuitikz (This is why I have no overlap here: this is with version 1.2.3).

enter image description here

 \draw  (0,-4) to [battery1,v=\SI{50}{V}] (3,-4); 
6
  • That moves both the polarity AND the label, and on my system, they overlap whether they are together above or together below. How can I get the polarity and the label on opposite sides? Commented Oct 1, 2020 at 17:02
  • Ah, ok. Wait...
    – Rmano
    Commented Oct 1, 2020 at 17:03
  • Your responsive answers is enough to love your package :)
    – Diaa
    Commented Oct 1, 2020 at 17:06
  • Thanks @Diaa :<3
    – Rmano
    Commented Oct 1, 2020 at 17:08
  • 1
    This really helps me move the label for an AC voltage source to the left side without losing the polarity sign. \draw (0, 8) to [sV={~}, l_=$V_0 cos(\omega t)$] ++(0, -4)
    – Leon Chang
    Commented Nov 2, 2023 at 1:50

You must log in to answer this question.

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