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).

  • 1
    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, 2010 at 11:11
  • 1
    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, 2010 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, 2010 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, 2010 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, 2010 at 21:35

2 Answers 2


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.


I have just posted an answer which includes a minimum working example for writing a class with pgfopt here: https://tex.stackexchange.com/a/553533/195759

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.