I built a class upon the article class. This class load a package where the \maketitle command is define. If I do not load babel inside the class, the title of the document is always in english (the date). Thus, I would like to pass the language in the class options, but I also would like to keep the possibility to load article class options. How can I do ?

I would like to do something like:

\documentclass[language, opt1, opt2]{myclass}

where in myclass, I send language to babel and opt1, opt2 to the article class. This is the beginnig of my class :

% default options

% load base class
\LoadClass[a4paper, 11pt]{article}

1 Answer 1


Giving the option globally can be a handy thing. The class file passes the options further to packages. You mentioned the language, let's have a look at it.

Internally, siunitx loads package translator (part of the beamer bundle). translator can see the global option for the language and react by using the right dictionary.

Another famous instance where a global option is passed to a package is draft.

\ProvidesClass{\jobname}[2014/10/15 test class TeX.SX]

\LoadClass[a4paper, 11pt]{article}

\Huge \@date
\usepackage{mwe}%loads graphicx
Let the pizza dough leaven for \SIrange{18}{24}{\hour}. Is the
draft option working here? hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh


Off-topic general advice
Are there any tripwires? Of course. Designing a new class is a delicate thing. The standard classes come with some basic options. The KOMA classes (a featureful enhancement of the standard bundle) come with a whole load of options to make almost any design change. Neither the standard nor KOMA classes do care of any locales (except letter vs DIN paper). The user is in charge.

An alternative to babel is polyglossia. Both do the same thing, but polyglossia has another syntax. So giving ngerman (or french) as a global option isn't known by polyglossia and hence ignored. Using the polyglossia syntax, translator won't know the option and hence ignore it.

You can catch some of the stuff, and take care of it, but it is impossible to take every little instance of user behaviour into account.

I once saw a custom class taking options via a key-value-syntax. Please replace draft by draft=true in the above example and take a look at the output. Package graphicx doesn't know the syntax and thus ignores it.

  • Yes it works! But what is the trick ? How Latex know that the french or ngerman option of the class have to be pass to babel and not another package ?
    – Ger
    Oct 15, 2014 at 13:43
  • 1
    If amsmath gets the option french or ngerman, it will just ignore it. siunitx will pick it up as well. Some new features of babel won't work with global options and need to be given as a package option directly.
    – Johannes_B
    Oct 15, 2014 at 14:17

You must log in to answer this question.

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