I lose track of all the different keyval packages. Can we maintain a list here? (Community wiki, one package per answer with a brief description of scope. I've started things off but need help completing it.)

  • 1
    This should be converted to a TUGboat article. Aug 28, 2011 at 20:24
  • 6
    @Martin — as soon as we'd do that someone would write another one! :) Aug 29, 2011 at 0:26
  • 1
    Why are there (more than) 13 keyval packages anyway?
    – You
    Dec 30, 2011 at 8:43
  • 3
    See also the survey article tug.org/TUGboat/tb30-1/tb94wright-keyval.pdf Dec 30, 2011 at 11:04
  • 1
    @JairoADelRio Not much point IMO. FWIW you could say this about any active area of LaTeX development. Because LaTeX has a smaller core and a much larger ecosystem, of course there are going to be more solutions to common problems. Also notable that of the 18 packages listed below, 6 are by one author and not much used, and others are more about interfacing keyval into class/package options rather than new keyval approaches per se. Jun 25, 2020 at 1:30

23 Answers 23


pgfkeys.sty, part of PGF/TikZ

Author: Till Tantau

  • I marked this entry up---it also counts for adding the other entries:-)
    – user10274
    Dec 30, 2011 at 9:23

l3keys.sty, part of expl3

Author: Joseph Wright (through the LaTeX3 Project)

Inspired by pgfkeys.

Use l3keys2e to use it in options of LaTeX2e packages and classes.



Author: Heiko Oberdiek

Supports keyval processing of package/class options.




Author: David Carlisle

The original and (probably) most widely used keyval package. Provides \define@key and \setkeys but all processing for special key-types must be done manually.

Removes one or two layers of braces around each "val".

Note: this package can have scope problems with nesting \setkeys. Nowadays I'd recommend a more modern alternative.

  • The keyval package strips off 2 levels of outer brace: one by using the space trimmer \KV@@sp@def and one in internal parsing.
    – Ahmed Musa
    Dec 31, 2011 at 1:54

LaTeX kernel

The LaTeX kernel's June 2022 update added key=val functionality (outside of expl3's l3keys), that is functionally equivalent to l3keys.

Defining keys is possible via \DeclareKeys[<module>]{<key-definitions>}, setting via \SetKeys[<module>]{<key=val-list>}.

Package and class options are supported via \ProcessKeyOptions[<module>].

  • 1
    Is there a good doc about this?
    – projetmbc
    Jun 24, 2022 at 6:50
  • 1
    @projetmbc documentation is in the making, should be added to usrguide3/usrguide. Currently you can fancy a peek in source2e in the ltkeys-section. There is also an intention to add documentation to clsguide.
    – Skillmon
    Jun 24, 2022 at 6:52
  • 1
    @projetmbc usage example on this site is available here. The <module> argument defaults to the current file name.
    – Skillmon
    Jun 24, 2022 at 6:53
  • So cute! I like that and will test it soon.
    – projetmbc
    Jun 24, 2022 at 12:07
  • It would be great to have the minimum LaTeX version where this is available. Jan 6, 2023 at 9:54


Author: Hendri Adriaens

Cannot be loaded before \documentclass.

Note: in the past controversial because it overwrites keyval's \setkeys macro and in some cases caused (long-standing) incompatibilities. But I believe any problems resulting from this are now fixed.

  • The xkeyval package strips off precisely 3 levels of outer braces in key values: one by using keyval’s space trimmer \KV@@sp@def and two in internal parsing. The keyreader package addresses this problem. Another problem with the xkeyval package is that its \setkeys command doesn't accept unbalanced conditionals. For example, \setkeys[KV]{fam}{key=\iffalse} fails. The next release of keyreader addresses this problem in its \krdsetkeys command. The selective sanitization scheme of xkeyval also appears unduly expensive when there are active commas and equals sign in key-vals.
    – Ahmed Musa
    Dec 31, 2011 at 2:05
  • Much of the reported incompatibility issue with xkeyval's \setkeys seems to have disappeared, even for keys defined by David Carlisle's original \define@key. kvsetkeys package later replaced its \setkeys with \kvsetkeys.
    – Ahmed Musa
    Dec 31, 2011 at 2:14
  • Is there any particular reason why it can't be loaded before \documentclass?
    – kahen
    Mar 5, 2012 at 17:48
  • Yes, by design. xkeyval needs to know the documentclass options for inheritance purposes. Not sure from a technical standpoint, though, why it can't pick them up along the way; haven't looked into the details recently. Apr 8, 2012 at 2:05
  • xkeyval.sty (not xkeyval.tex) needs the \@classoptionslist macro for (1) filtering =<value> from the class options list and (2) for class and package options processing with \ProcessOptionsX*. The keyreader packages delays the search for \@classoptionslist and the actions mentioned at (1) and (2) above until \documentclass was instantiated later by the document.
    – Ahmed Musa
    Nov 8, 2012 at 15:06


Author: Markus Kohm

It's part of KOMA-Script and documented in scrguide-en.pdf (English) and scrguide-de.pdf (German). It provides a family hierarchy for key-values and a processing of class and package options. With newer LaTeX kernels it uses the new raw option feature for key-value-options, but still provides a complex (but not easy to understand) feature to report unprocessed values. It also provides several types of values, like integers, length, strings, switches and a mapping from symbolic to numeric values.

I never used it my self so I can’t say more about it …



Author: Heiko Oberdiek

  • 2
    kvsetkeys only sets keys; it doesn't define them. It strips one level of outer curly braces in key values.
    – Ahmed Musa
    Dec 31, 2011 at 2:20


Author: Joseph Wright

Allows pgfkeys processing to be performed on class or package options.

  • It's not really a keyval package :-)
    – Joseph Wright
    Aug 28, 2011 at 16:46
  • 3
    Counts for me :) Aug 28, 2011 at 16:50


Author: Ahmed Musa

The package provides a robust interface to controlling keys in xkeyval, removing some of that package’s restrictions.

  • @AhmedMusa: done! Jan 2, 2012 at 17:33
  • @Ahmed — your comments should be additional answers on this page! Jan 29, 2012 at 21:04
  • Also, this page is supposed to be comprehensive. It makes no sense to remove an entry! I've added skeyval below. Jan 29, 2012 at 21:09


Author: Paul Isambert

Part of the author's collection of plain tex/generic packages.

Looks nice, but I've never used the macros. Syntax highly eccentric, as viewed by a latex user...



Author: Jonathan P. Spratte

expkv is the only fully expandable key=val parser (in addition to the basic \keyval_parse:NNn of l3keys which was modelled after expkv's implementation of \ekvparse).

The bundle consists of multiple packages:


The package alone does only provide features comparable with keyval (the macros are called \ekvdef, \ekvdefNoVal, and \ekvset), but it does only strip one set of braces and only after spaces are stripped, and it does work for active commas and equals signs. As of writing this, it is the fastest key=val parser with robust parsing (in the sense of the aforementioned brace and category code safety).

Additional utility packages by the same author are available to extend expkv's features:


Provides key-types similar to pgfkeys or l3keys, definable in a key=val interface. Many of the key types aren't expandable (because they do assignments).


Define expandable macros with a key=val argument. The package allows two different syntax variants, one will split the keys into separate arguments (#1 ... #9) the other will provide a list in which values can be accessed by the key names.


Parse LaTeX class and package options with expkv.

Except for expkv-opt all the packages can be used in plainTeX, LaTeX, and ConTeXt.



Author: Ahmed Musa

From the package description:

The package extends and improves the robustness of the pgfkeys package. In particular, it can deal with active comma, equality sign, and slash in key parsing. The difficulty with active characters has long been a problem with the pgfkeys package.

With any luck, this facility can be merged into the main code of pdfkeys directly. Unless this robustifying is too resource intensive, I supposed.

Edits by Skillmon:

Up to today (2020-06-23) this package wasn't integrated into pgfkeys. It fixes two of the bugs pgfkeys has (I only know of these two bugs), namely it doesn't strip any braces before space stripping, and it works even if commas or equals signs are made active.

Starting with commit 1e520dc7 to pgfkeys, pgfkeyx is no longer compatible with it.

The author's statement

pgfkeyx is not any significantly more resource-intensive than the original pgfkeys.

however isn't true. The following shows the results of benchmarking pgfkeys and pgfkeyx. The dots are the benchmarking results, the lines are the interpolations on them, linear for pgfkeys (blue) and quadratic for pgfkeyx (red).

enter image description here

  • The integration of pgfkeyx with pgfkeys was suggested by the author of pgfkeyx. pgfkeyx is not any significantly more resource-intensive than the original pgfkeys.
    – Ahmed Musa
    Nov 8, 2012 at 15:15
  • Is this package still needed or has it been integrated?
    – cfr
    Sep 21, 2017 at 22:07
  • The two packages probably still differ I'd guess. Perhaps @JosephWright knows more? Sep 22, 2017 at 12:58
  • @cfr if you're still interested, see my edits.
    – Skillmon
    Jun 23, 2020 at 18:47

Opmac tricks 0069 and 0114, OpTeX trick 0008

Author: Petr Olsak.

OPmac tricks 0069 and 0114 are usable for plain TeX with OPmac macros, OpTeX trick 0008 is intended for OpTeX format.



Author: Josef Friedrich

A Lua module for parsing key-value options


  • Key-value pairs can be parsed independently of the macro collection (LaTeX or ConTeXt). Even in plain LuaTEX keys can be parsed.
  • luakeys can handle nested lists of key-value pairs, i.e. it can handle a recursive data structure of keys.
  • Keys do not have to be defined, but can they can be defined.


  • The package works only in combination with LuaTeX.
  • You need to know two languages: TeX and Lua.


Author: Daan Leijen

Inspired by pgfkeys and in fact very similar, but faster. It also supports parsing class and package options.



Author: Christian Tellechea

Documentation is only available in French. It is pretty fast and unconventional in the way undefined keys are handled (they get stored as new keys and no error is thrown).



Author: Ahmed Musa

Superceded by ltxkeys.

  • Much of the functionality of skeycommand has been moved to ltxkeys, as indicated in the sub-title of skeycommand documentation. But my recent experience shows that it's nearly impossible to abandon a package, once it has been released to CTAN. It will resurface somewhere someday.
    – Ahmed Musa
    Dec 30, 2011 at 8:31
  • 1
    Shouldn't be used as it loads the problematic catoptions package.
    – Skillmon
    Jun 30, 2020 at 16:51


Author: Ahmed Musa

ltxkeys, unlike keyreader, is completely independent of xkeyval and provides many more features. It can be loaded before \documentclass.



Author: Ahmed Musa

The package (version 1.3) is incompatible with LaTeX 2020/10/01 and newer

The skeyval package provides commands for compactly defining and initializing all types of key (ordinary, command, boolean, style, choice, etc). It attempts to combine the features of ltxkeys package (which has the syntax of the xkeyval package) and pgfkeys package. See Possibility to pass options to packages.



Author: Ahmed Musa

This was meant to be lightweight, with no facility for options processing.



Author: Michael Downes

Keyval syntax is restricted in a sense that options must always be surrounded by braces.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .