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

How to pass a keyval string option given to my package to babel?

I load my package with


In package mylang I want to handle this optional languages parameter and hand it over to babel. If the option is missing I want to define a default value.

My attempt:


But how to go on from there? I think the default value is set correctly but how to hand it over to babel now? Do I need to run the default process option routine?

For a non keyval value I would use

share|improve this question
kvoptions allow to use DeclareOption. – Marco Daniel Sep 30 '11 at 11:08
But how to use kvoptions' DeclareOption then to pass the languages keyval options to babel? – Sebastian Sep 30 '11 at 11:17
up vote 7 down vote accepted

It is not really an answer but I want to show a minimal working example in relation to mhp answer.

DeclareStringOption (important is the order)



share|improve this answer
Works like a charm. Hint: my package name contained numbers and therefore I had to set the prefix myself since the macro \L10n@langiages didn't work with numbers. – Sebastian Oct 3 '11 at 13:02

The value of an option declared with \DeclareStringOption is stored in the macro \<package>@<option>. Hence, try







If you prefer a shorter prefix than mylang@ use \SetupKeyvalOptions before declaring options, e.g.:

\SetupKeyvalOptions{family=ML, prefix=ML@}
share|improve this answer
I get errors: "missing \endscname inserted \ProcessOptions*" – Sebastian Oct 1 '11 at 10:31
@Sebastian: Look at the answer of Marco, he's built a minimal working example around my code. It should definitely work. – mhp Oct 1 '11 at 19:54
@mhp: please compare the \DeclareStringOption in the mwe and in your code. – Marco Daniel Oct 1 '11 at 21:23
@Marco: OK, I see. In contrast to Sebastian, you don't specify a default value, but an initial value for the languages option. In fact, this is a better approach since it allows the babel package to be loaded without options at all. But I don't think the error reported by Sebastian is related thereto. – mhp Oct 2 '11 at 17:39
@mhp: You are right. – Marco Daniel Oct 2 '11 at 18:59

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.