TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I pass two parameters to a tikz style? I would like to do something like this:

    transformer/.style={draw, cylinder, gray!80, rotate=90, minimum height=#1, minimum width=#2},

And then, I want to use this style in a node:

\node [transformer{2.3cm}{1cm}] () at (0,0.6) {};
share|improve this question
Use style 2 args, see page 493 of the manual (sorry, I'm currently to lazy to write and test a complete answer). – Caramdir Jun 22 '11 at 19:02
@Caramdir: Thanks for the link. Much appreciated — absolutely no need to apologize. – Neil G Jun 22 '11 at 19:04
I think you have to use something like [transformer={2.3cm}{1cm}] – Peter Grill Jun 22 '11 at 19:04
up vote 21 down vote accepted

    transformer/.style 2 args={draw, cylinder, gray!80, rotate=90, minimum height=#1, minimum width=#2}]

\node [transformer={2.3cm}{1cm}] () at (0,0.6) {};
share|improve this answer
Indeed, there is also .style n args={<number of args>}{<style>} for more arguments and .style args={<parameter text>}{<style>} which allows to define the arguments using a parameter text like \def does. – Martin Scharrer Jun 22 '11 at 21:04
how can I achieve this with using \tikzstyle ? – bonanza Feb 25 at 16:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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