TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

Is there a tutorial on how to create a package or class with pgfkeys/pgfopts that goes beyond this pdf? keyval.pdf

In particular I would be interested on how I can create package/class options and new commands that pass options to tikz-drawings (such as colours, line length/width, shape).

share|improve this question
Your link pointed to the draft version of a TUGboat article. Meanwhile, the definite version has been made publicly available, I've edited your link accordingly. – lockstep Sep 3 '10 at 11:11
The article was deliberately general: what the options do is more-or-less up to you. I was aiming at pgfkeys as a general system rather than being tied to Tikz. – Joseph Wright Sep 3 '10 at 12:30
Well i guess if you can use it general, you can fairly easy apply it to tikz. However, I am not a programmer and I stuggle to get started. Since I am interested in the use with tikz I don't really want to get into keyval... – Martin H Sep 3 '10 at 17:48
I'm intrigued that you want to write a package but not have any programming. Can you explain the general plan: this would help with a good answer. – Joseph Wright Sep 3 '10 at 19:52
Don't get me wrong, I just meant that I don't have a degree in programming/computer science. I use LaTeX for severals years now and I can write bits of C code Matlab and VBA... The idea in my head is to create something like a class or package for a CV. I find moderncv ok, but I think the design could be better/more adjustable and I thought it could be done with tikz quite nicely. – Martin H Sep 3 '10 at 21:35
up vote 2 down vote accepted

I assume you read the section of the pgf manual that documents pgfkeys. If you haven't, read it. Many times.

But knowing what the commands do isn't the same as knowing how to use them. Try looking at some source code for best practices. Maybe Christian Feuersänger's pgfplots package?

I'm trying to use pgfkeys for my packages, too, and I think the idea is to create a style for your objects and add your initial keys to those styles for defaults. Then if other keys are to change styles of other objects they can append to those styles.

share|improve this answer
To avoid this comment getting lost below the OP, I'll post it here: I just posted an example at tex.stackexchange.com/questions/185975/… – sdaau Jun 21 '14 at 21:54

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.