2

When I make a simple circuit containing a cell with to[battery2, V=$1.5V$] and a resistor (R), I get the circle for the battery symbol:

\documentclass{article} 
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) to[battery2, V=$1.5V$] (0,2)
to[short, i=$I_0$] (2,2)
to[R] (2,0)
to[short] (0,0)
;
\end{circuitikz}
\end{document}

If I leave out the info for the battery and just use to[battery2], I get the battery symbol consisting of the long and short bar.

\documentclass{article}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) to[battery2] (0,2)
to[short, i=$I_0$] (2,2)
to[R] (2,0)
to[short] (0,0)
;
\end{circuitikz}
\end{document}

Why is my battery symbol changing? I want to keep the long and short bar symbol for my battery.

3
  • Welcome to TeX:SE! You should use [battery2, v=$1.5V$] (V is wrong, it call symbol for voltage generator).
    – Zarko
    Jan 26, 2022 at 21:22
  • Thanks so much, I knew it was something trivial! (but not a trivial result.)
    – larryjb
    Jan 26, 2022 at 21:41
  • Notice that $1.5V$ really means 1.5 multiplied by the variable V. If you want to say "1.5 volts", better use \qty{1.5}{V} with the siunitx package (print both side to side and observe the difference!).
    – Rmano
    Jan 27, 2022 at 16:14

2 Answers 2

2

Let me spell out my comment to an answer ...

  • With V is designate european voltages source (see 4.5.2 Stationary sources, page 63 and note in frame on page 64)
  • v indicate voltage drop over pasive elements (R, C, L) or generated voltage at voltage source
  • If two you write two elements in path options as you do in MWE (Minimal Working Example) in your question, prevail the last one.

Correct code for your circuit scheme is:

\documentclass[border=3.141592]{standalone}
\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}
\draw (0,0) to [battery2, v=$1.5V$] (0,2)
            to[short, i=$I_0$] (2,2)
            to[R] (2,0)
            to[short] (0,0)
            ;
\end{circuitikz}
\end{document}

enter image description here

1
  • Very good answer, you explain why the OP's code is not working. Thanks!
    – Rmano
    Jan 27, 2022 at 16:16
0

You can use features available in tikz package as

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usepackage[american voltages, american currents, siunitx]{circuitikz}

\begin{document}
\begin{circuitikz}
\draw (0,0) to [battery2, l=1.5<\volt>, invert] (0,2)
    to [short, i=$I_0$] (2,2)
    to [R] (2,0)
    to (0,0)
;
\end{circuitikz}
\end{document}

enter image description here

Even the environment circuitikz can be changed into that of `tikzpicture' for the same output as

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usepackage[american voltages, american currents, siunitx]{circuitikz}

\begin{document}
\begin{tikzpicture}
\draw (0,0) to [battery2, l=1.5<\volt>, invert] (0,2)
    to [short, i=$I_0$] (2,2)
    to [R] (2,0)
    to (0,0)
;
\end{tikzpicture}
\end{document}
1
  • circuitikz and tikzpicture are always exactly the same... historical thing. I am thinking of removing circuitikz from the manual altogether. As a side note, the special siunitx syntax is not really robust, I suggest using l=\SI{1.5}{\volt} (or l=\qty[1.5}{\volt} with siunitx v3).
    – Rmano
    Jan 27, 2022 at 16:12

You must log in to answer this question.

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