Is it possible to produce a variable battery1 sign (battery with one up slanted arrow) in circuitikz? There are options for vR and vL (variable resistor) but not for the battery1. I need it to represent a variable power supply. MWE is appended below

 \draw   (0,-2) to[battery1] (2,-2) node [right] {Powersupply};

Generated from MWE What I want What I want

I can manually put an up arrow and position it to the middle of battery1 sign but any shortcut like vR or vL would help.


Just define your own component. I copy&pasted the battery1 definition and added the arrow.



\compattikzset{battery2/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@battery2@path, \circuitikzbasekey/bipole/is voltage=true, v=#1}}







 \draw   (0,-2) to[battery2] (2,-2) node [right] {Powersupply};



  • 1
    Thanks @Benjamin for a quick reply. This macro is giving me an error 'Undefined control sequence. l.7 \compattikzset {battery2/.style...... ' What shall I do about it? Sorry if it is a trivial question. I am not an expert in tikz and writing a macro. Jan 22 '16 at 11:17
  • Did you accidentally missed adding the \usepackage{...} line?
    – Benjamin
    Jan 22 '16 at 11:29
  • No!. I copied your whole code and pasted it. I ran this MWE independently and still... same error. Wondering if there is anything wrong with my circuitikz.sty file. Jan 23 '16 at 8:45
  • Which version of circuitikz do you have installed? Add a \listfiles at the beginning of the tex file (even before \documentclass{...}) to get a list of all the packages used with the corresponding version numbers in the log file.
    – Benjamin
    Jan 23 '16 at 10:47
  • it says circuitikz.sty 2012/12/29 The CircuiTikz circuit drawing package version 0.3.0 Jan 24 '16 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.