Take the 2-minute tour ×
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.

I am searching for a possibility to give additional options to another package.
I have tried it with \PassOptionsToPackage.

My idea was that I can use something like \documentclass[hyperref={bookmarksnumbered=true}]{asjgdhoia}.

cls file:

\ProvidesClass{asjgdhoia}[2012/02/10 Mini class for testing proposal]

tex file:


Finally there is a simple solution using \textsc{\textbf{XMLResource.OPTION\_RECORD\_UNKNOWN\_FEATURE}} option. And the
text must go on \ldots.
And another example the show must go on, but we have too less text (\textbf{createUnspecifiedNodeWarningMarker} and
\textbf{createUnspecifiedNodeErrorMarker}, sdjklashjksa \textbf{createUnspecifiedLinkWarningMarker} and
share|improve this question
I believe that unused documentclass options are offered to all loaded packages anyway, until they're grabbed so just [bookmarksnumbered=true] should work, no? –  Brent.Longborough Aug 10 '12 at 8:21
@Brent.Longborough: This works ;-) –  Marco Daniel Aug 10 '12 at 8:25
Interesting I have never tried it. :) –  CSchulz Aug 10 '12 at 8:45
add comment

3 Answers

Regarding the question of packages using the same option names, there is no problem in that instance. If you're using xkeyval package, you only need to be cautious with your use of \ProcessOptionsX*, especially in a class file. See page 19 of the documentation for the xkeyval package for an example. Here is a quote from there:

The use of \ProcessOptionsX* in a class file might be tricky since the class could also be used as a basis for another package or class using \LoadClass. In that case, depending on the options system of the document class, the behavior of the class loaded with \LoadClass could change compared to the situation when it is loaded by \documentclass. But, since it is technically possible to create two classes that cooperate, the xkeyval package allows for the usage of \ProcessOptionsX* in class files.

Notice that using LaTeX's \ProcessOptions or \ProcessOptions*, a class file cannot copy document class options. In case you want to verify whether your class is loaded with \documentclass or \LoadClass, you can use the \XKV@documentclass macro, which contains the current document class.

There are many key-value parsers (see the list at a big list of key-value packages). Below I make some comments on some of them.


In the case of the xkeyval package, you may want to note the following:

The xkeyval package has many interesting features, such as the use of pointers, presetting and post-setting keys, family filtering, and setting rm (remaining keys) as many times as you may wish. It is also efficient in computational resource utilization. To define and set a key, its runtime is much shorter than that of pgfkeys, and it defines far fewer macros than pgfkeys.

But, like every package, it has some shortcomings (if that is an appropriate word to use here). Some of its drawbacks include:

  1. It can't be loaded before \documentclass, but you can load keyreader package before \documentclass. The keyreader package redefines some internals of xkeyval and provides a frontend to xkeyval.

  2. This one isn't a serious drawback, but the xkeyval package can't accept default values with parameter characters. Perhaps David Carlisle's original idea of a key-value system excluded the need for this feature. For example, the following (A) fails.

  3. It strips up to three levels of outer braces in key values. If preserving braces is important to you, then you need to pad your key values with additional braces.

  4. Its stack management system leaves room for improvement. To allow \setkeys to be infinitely re-entrant (Oberdiek test), it saves the current "state vector" of \setkeys before calling \setkeys. The way this is done by xkeyval is not efficient: iterations to build the stack are done twice (one for pushing and one for popping the stack) for each call to \setkeys. The keyreader package uses only one iteration both for going down and coming up the stack.

  5. The macro \CurrentOption was missing from the state vector of xkeyval's \setkeys. This may cause problems when \setkeys is nested. I have had an unpleasant experience in this regard. Version v2.6b (2012/10/14) of the package corrected this omission.

  6. Unlike pgfkeys, the xkeyval package has no provision for (a) expanding the value of a key at setting keys, (b) updating the callback of an existing key at runtime, (c) style/observer keys, (d) multi-parameter callbacks, (e) family filtering -- although it has key filtering via rm keys. These features are provided by version 1.1 (2012/08/01) of the skeyval package.

  7. Its selective sanitization scheme of Uwe Kern, which it deploys to cope with babel, leaves room for improvement. It's more expensive than search-replace sanitization schemes.

  8. The development of xkeyval has ceased since 2008. Version v2.6b (2012/10/14) corrected a few bugs but provided no new features.

Code (A):


Code (B):



In the case of the pgfkeys package, you may want to note the following:

  1. The handler system of pgfkeys is a great attraction, but you need some experience to use it effectively. Because of this feature and the pgf/tikz graphics bundle, pgfkeys is popular, despite its relatively higher computational overhead.

  2. If babel is loaded with certain options, key parsing by pgfkeys may fail, unless you load pgfkeyx package.

  3. pgfkeys package on its own doesn't process package or class options. For options processing, you need pgfopts package.

  4. This one is a personal opinion. I find key and family filtering less convenient to manipulate using pgfkeys than with xkeyval and skeyval packages. It will be interesting to have pgfkeys' handler mechanism implemented for xkeyval package or a supported package with a similar syntax. This is attempted by version 1.1 (2012/08/01) of the skeyval package. With the skeyval package, you filter out a key, family or path by simply calling the .ignore handler. For example,

      % Start off on two separate paths:
      .paths = {KV1/fam1,KV2/fam2},
      .initialize keys after define,
      .define keys = {
        .exec code = \def\iden#1{#1},
        % Define 1 ordinary key. Only the keyname field is mandatory, but
        % we have filled all the fields here:
        % Define 2 choice keys with the same attributes. Choice keys can have 
        % default value, state pattern or binding set, code for valid value, and 
        % code for illegal value. Only the keyname field is mandatory.
             \typeout{Value of key `\skvcurrentkey' is invalid; `justified' assumed}
        % The starred (*) form of choice key will always use the lowercase of the 
        % user input to match the singleton:
         }/\def\val{Value of key4: #1}
      .exec code = \def\acenter{center},
      % In Java speak, keya and keyb are subjects of the observer key1.
      % The observer can subscribe to attributes of the subject. In the
      % following example, the observer (key1) asks to be notified of the value
      % of the subject:
      .style = {keya,keyb}/key1=#1,
      % Don't set key1 and key2 on path KV1/fam1:
      .ignore path = KV1/fam1,
      % Ignore key3 and key4 on all active paths:
      .ignore keys = {key3,key4},
      .set keys = {
         % Check the logfile for a warning about the invalid value of key2:
         key1=value1, key2=value2, key3=.expand once{\acenter}
      .restore keys = {key3,key4},
      .restore path = KV1/fam1
share|improve this answer
add comment

Global options with curly braces:


will not work if the class loads a KOMA-Script class, because of a limitation/bug of KOMA-Script, when its processes the options.

But the following syntax can be supported:


Package kvoptions handles key value options for classes and packages and package kvsetkeys defines a key value parser than is not confused by several equal signs. The first equal sign separates the key from the value.

Class asjgdhoia:

\ProvidesClass{asjgdhoia}[2012/02/10 Mini class for testing proposal]



% hyperref options:

% bookmark options:
\def\asjgdhoia@bookmark{% default setting







  • There is a new hyperref option hidelinks.
  • Package bookmark is added (more features, less or even none LaTeX reruns needed).
  • The handling of option bookmark shows an alternative to the method of \PassOptionsToPackage. If the options is called more than once, then the options are concatenated as in option hyperref. If the option should overwrite previous option settings, then option bookmark can be defined as follows:

  • Option paper=a4 is passed to package typearea.

share|improve this answer
add comment

You want to setup a so called key-value syntax. LaTeX doesn't support this by default. You have to use a keyval package.

The question A big list of every keyval package lists all keyval packages.

Examples for using can be found here to:

I am sure you will find more related questions.

I don't want to provide an example because you should ask a a separate question with your favorite keyval package.

By the way options of the documentclass will be passed to every loaded package:

\ProvidesClass{asjgdhoia}[2012/02/10 Mini class for testing proposal]
%                 colorlinks=true,%




share|improve this answer
I am sure the second part is answered in an other question. –  Marco Daniel Aug 10 '12 at 8:29
The only problem is for example if there are packages which uses same options. –  CSchulz Aug 10 '12 at 9:34
@CSchulz: Indeed –  Marco Daniel Aug 10 '12 at 9:37
I will have a look on the keyval packages. –  CSchulz Aug 10 '12 at 9:38
@MarcoDaniel: pgfkeys has nothing to do with (package/class) options. You need pgfopts. And kvopstions should be kvoptions, so that the OP doesn't try to find what doesn't exist. –  Ahmed Musa Aug 10 '12 at 12:31
show 2 more comments

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.