# TikZ/CircuiTikZ battery symbol

How can I get a battery symbol like this from either CircuiTikZ or TikZ's circuit libraries? I haven't been able to find any that have a thick negative terminal. pst-circ's \battery command is exactly what I want, but I'd prefer to stick to TikZ.

MWE:

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{circuits.ee.IEC}

\begin{document}
\begin{tikzpicture}[circuit ee IEC]
\draw (0, 1) to [battery] (0, 0) {};
\end{tikzpicture}
\end{document}


• The third answer in tex.stackexchange.com/questions/33649/… does almost everything for you. You just hve to change the line thickness. – John Kormylo Oct 10 '15 at 15:46
• @JohnKormylo, that changes the thickness of both terminals, I only want the negative terminal to be thicker. – JamesNZ Oct 11 '15 at 1:33

## 1 Answer

Perhaps I should have mentioned that you also have to split the component into two paths to implement two different line widths,

Note, you probably could reuse \linethickness instead of \tempwidth. A quick search of sty files only found it used in geometry and gkpmac(?). Besides, local changes won't get out of tikzpicture.

\documentclass{standalone}
\usepackage{circuitikz}

\newlength{\tempwidth}

\makeatletter
\ctikzset{bipoles/battery/width/.initial=.1}
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/battery/height}}{battery}{\ctikzvalof{bipoles/battery/height}}{\ctikzvalof{bipoles/battery/width}}{
\pgf@circ@res@step = -\ctikzvalof{bipoles/battery/width}
\pgf@circ@Rlen \divide \pgf@circ@res@step by 2
\tempwidth=\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth

\pgfsetlinewidth{\tempwidth}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
\pgfusepath{draw}

\pgfsetlinewidth{2\tempwidth}
\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{.5\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{.5\pgf@circ@res@down}}
\pgfusepath{draw}
}
\makeatother

\begin{document}
\begin{tikzpicture}
\draw (0, 1) to [battery] (0, 0) {};
\end{tikzpicture}
\end{document}


• Your battery symbol should be included into circuitikz as an option in selecting of battery symbols. – Zarko Oct 11 '15 at 15:33
• @Zarko - I have no control over circuitikz, but I can add it to my collection elfsoft2000.com/projects/index.htm – John Kormylo Oct 11 '15 at 15:35
• well, maybe you would write to author of circuitikz, that he include your impressive collection images. Thank you for link, it will be very useful for me. – Zarko Oct 11 '15 at 18:04
• I have included the symbol to circuitikz named "battery2". It will be part of the next release and can be tried using the gitversion from here circuitikz.github.io/circuitikz – sistlind Sep 12 '16 at 15:20