73

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. – Martin Schröder Aug 28 '11 at 20:24
  • 6
    @Martin — as soon as we'd do that someone would write another one! :) – Will Robertson Aug 29 '11 at 00:26
  • i'd second what @will says: i constructed a list, but in two months, two more (getoptk -- a slightly weird thing, and ltxkeys) have appeared. – wasteofspace Aug 30 '11 at 21:14
  • 1
    Why are there (more than) 13 keyval packages anyway? – You Dec 30 '11 at 08:43
  • 3
    See also the survey article http://www.tug.org/TUGboat/tb30-1/tb94wright-keyval.pdf – Christian Feuersänger Dec 30 '11 at 11:04
  • @You - Some of the packages emerged from a desire to address a shortcoming identified with an existing package, to add features to an existing package, to attend to a personal need (or even desire) of the author or of a requestor, or simply to experiment with coding. – Ahmed Musa Dec 31 '11 at 06:41
  • Wow. I've just seen this. Another reason to prefer ConTeXt unified treatment of key-value pairs. Btw, do ConTeXt modules count as answers? –  Jun 23 '20 at 18:52
  • 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. – Will Robertson Jun 25 '20 at 01:30
  • The following topic “Key-Val: packages with key-value argument systems” on CTAN also gives a good overview of the available keyval packages. – JosefFriedrich Dec 30 '22 at 15:28

23 Answers23

25

pgfkeys.sty, part of PGF/TikZ

Author: Till Tantau

  • I marked this entry up---it also counts for adding the other entries:-) –  Dec 30 '11 at 09:23
16

kvoptions.sty

Author: Heiko Oberdiek

Supports keyval processing of package/class options.

Manual

16

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.

13

keyval.sty

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 '11 at 01:54
12

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

Skillmon
  • 60,462
8

xkeyval.sty

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 '11 at 02: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 '11 at 02:14
  • Is there any particular reason why it can't be loaded before \documentclass? – kahen Mar 05 '12 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. – Will Robertson Apr 08 '12 at 02: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 08 '12 at 15:06
7

scrbase.sty

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 …

cabohah
  • 11,455
Tobi
  • 56,353
6

kvsetkeys.sty

Author: Heiko Oberdiek

Gonzalo Medina
  • 505,128
  • 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 '11 at 02:20
6

keyreader.sty

Author: Ahmed Musa

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

Gonzalo Medina
  • 505,128
6

pgfopts.sty

Author: Joseph Wright

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

5

yax.tex

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

wasteofspace
  • 5,352
5

expkv-bundle

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:

expkv

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:

expkv-def

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

expkv-cs

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.

expkv-opt

Parse LaTeX class and package options with expkv.


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

Skillmon
  • 60,462
2

keycommand.sty

Author: Florent Chervet

2

pgfkeyx.sty

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

Skillmon
  • 60,462
2

options

Author: Daan Leijen

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

Skillmon
  • 60,462
2

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.

wipet
  • 74,238
1

keyval2e.sty

Author: Ahmed Musa

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

1

ltxkeys.sty

Author: Ahmed Musa

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

1

skeycommand.sty

Author: Ahmed Musa

Superceded by ltxkeys.

Gonzalo Medina
  • 505,128
1

skeyval.sty

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.

1

simplekv

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

Skillmon
  • 60,462
1

luakeys

Author: Josef Friedrich

A Lua module for parsing key-value options

Pros

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

Cons

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

rkeyval.sty

Author: Michael Downes

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