[texhax] Extending babel's vocabulary from a document class?

Morten Høgholm moho01ab at student.cbs.dk
Wed Jun 16 12:00:16 CEST 2004


On Tue, 15 Jun 2004 21:54:37 +0100, Christer Thörn <df03toch at ing.hj.se>  
wrote:

> When I try it, I get undefined control sequence on \addto, and if I use  
> \RequirePackage[swedish]{babel} in the class it clashes if I use  
> \usepackage[english]{babel} in a document based on the class (and vice  
> versa). How do I resolve that?

Specify the languages as global options in \documentclass. However this  
always give you Swedish as your main language. If this is not desireable  
you could add the line
   \let\setmainlanguage\main at language
to your class file, so that you have a user command. Also in English you  
should have the strings for \lst...name like in this complete example:

%%%%
\begin{filecontents}{CTclass.cls}
\ProvidesClass{CTclass}[2004/06/16 v0.01 Example Class]
\RequirePackage[swedish]{babel}
\let\setmainlanguage\main at language
\addto\captionsswedish{%
   \def\lstlistingname{Kodlistning}%
   \def\lstlistlistingname{Kodlistningar}%
}
\LoadClass[a4paper]{article}% just for illustrating...
\end{filecontents}
\documentclass[english]{CTclass}
\usepackage{listings}
\setmainlanguage{english}
\addto\captionsenglish{%
   \def\lstlistingname{Listing}%
   \def\lstlistlistingname{Listings}%
}
\begin{document}
\chaptername, \lstlistingname, text in English

\selectlanguage{swedish}
\chaptername, \lstlistingname, text p"w svensk

\selectlanguage{english}
\chaptername, \lstlistingname, text in English
\end{document}
%%%%
-- 
Morten Høgholm



More information about the texhax mailing list