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'm writing a new class file that is based on book, and thought of making it available both in an English and in a Dutch version. Easiest to do seemed passing the arguments, so I constructed following class file :

...
\ProvidesClass{UGentCourse}[2011/07/28 v1.0 UGentCourse]

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
\ProcessOptions \relax
\LoadClass[12pt,a4paper,twoside]{book}

\RequirePackage{babel} %francais, polish, spanish, ...
...

Which I believed would allow me to do :

\documentclass[dutch]{UGentCourse}

Strange thing, it doesn't work completely. If I switch it from dutch to English (or back), I get an error :

Package babel Error: You haven't loaded the option english (dutch) yet.

If I rerun the file, the error is gone. I have a faint idea about what is going on, but not really a clue of how I can prevent this from happening. All help appreciated.

share|improve this question
5  
It's normal; babel writes the language in the .aux file. If you change from Dutch to English, at the subsequent compilation LaTeX finds the annotation about Dutch and doesn't know about the language. –  egreg Jul 29 '11 at 11:40
    
I realized. I just need a way to get rid of that. Which @mhp gave me, thanks for that. –  Joris Meys Jul 29 '11 at 13:26

1 Answer 1

up vote 7 down vote accepted

You can avoid this error by modifying your class definition as follows:

\ProvidesClass{UGentCourse}[2011/07/28 v1.0 UGentCourse]

\DeclareOption{english}{\AtEndOfClass{\main@language{english}}}
\DeclareOption{dutch}{\AtEndOfClass{\main@language{dutch}}}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}

\ProcessOptions\relax

\LoadClass[12pt,a4paper,twoside]{book}

\RequirePackage[dutch, english]{babel}

The last language in the option list passed to the babel package (i.e. english here) is the default language. It is active at the beginning of the document if no language has been specified in the optional argument of \documentclass.

share|improve this answer
    
Thx, this works smoothly. –  Joris Meys Jul 29 '11 at 13:26

Your Answer

 
discard

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.