Tx · LaTeX & TikZ

How to Draw a Battery Symbol in TikZ/CircuiTikZ

Published By the 9to5Science editorial team

At a glance

  1. 1. Load CircuiTikZ

    Add the circuitikz package to your document and place the symbol inside a circuitikz environment.

  2. 2. Add the component

    Use to[battery] between two coordinates in a draw path.

  3. 3. Set direction and label

    Choose the path direction and add a label with the l option if needed.

CircuiTikZ draws circuit symbols as components along paths. To make a battery, use the component name battery in a to operation, with a coordinate at each end. The example below is a complete document you can compile.

Minimal working example

\documentclass{article}
\usepackage{circuitikz}

\begin{document}
\begin{center}
\begin{circuitikz}
  \draw (0,0) to[battery, l=$V$] (0,2)
        to[R, l=$R$] (3,2)
        -- (3,0)
        -- (0,0);
\end{circuitikz}
\end{center}
\end{document}

The circuitikz package provides the circuit drawing commands and loads TikZ support. The first to operation places a battery between (0,0) and (0,2). The l=$V$ option adds a label; R places a resistor on the next path segment. The -- operations draw plain wires to close the circuit.

If you only want the battery symbol, the essential command is:

\draw (0,0) to[battery] (3,0);

The component follows the direction between the two coordinates, so you can draw it horizontally or vertically by changing those coordinates. In a longer circuit, use to[battery] as one part of the same path, or start a separate \draw path for it.

Adding labels and changing direction

CircuiTikZ uses l= for a component label. For example, to[battery, l=$V_1$] labels the battery with V1V_1. The label text is ordinary LaTeX math or text, so you can use subscripts or other formatting.

To change the battery’s direction, change the order or positions of its endpoint coordinates. For a vertical symbol, use coordinates such as (0,0) and (0,2); for a horizontal one, use (0,0) and (3,0). The symbol remains attached to the path, and any remaining distance is drawn as wire where needed.

Common mistakes

  • Loading only TikZ: \usepackage{tikz} provides general drawing tools, but the battery circuit component is supplied by circuitikz. Load \usepackage{circuitikz}.
  • Using the command outside the environment: Put the drawing path inside \begin{circuitikz} and \end{circuitikz}.
  • Forgetting the endpoints: A to[battery] operation needs a starting point and an ending coordinate, such as (0,0) to[battery] (3,0).
  • Confusing labels with component names: battery selects the symbol; l=$V$ adds text beside it. Use both options separated by a comma when you want a labeled battery.

If compilation reports an unknown component, check that CircuiTikZ is installed and that the component key is spelled battery in lowercase.

References

  1. CircuiTikZ package documentation

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.