[Tex/LaTex] TikZ/CircuiTikZ battery symbol

circuitikzcircuitstikz-pgf

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.

enter image description here

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}

enter image description here

Best 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}

battery