I have been trying to create a package, which loads the babel
package and sets the language with an option. I've been getting strange errors when trying to define mutually exclusive package options, so as to prevent babel
options conflict. I've put together a MWE
. Here is the failedpackage.sty
file :
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{failedpackage}
\newif\ifbabel@french
\newif\ifbabel@english
\newif\ifbabel@german
%% Option zone
\DeclareOption{french}{\babel@frenchtrue\babel@englishfalse\babel@germanfalse}
\DeclareOption{english}{\babel@frenchfalse\babel@englishtrue\babel@germanfalse}
\DeclareOption{german}{\babel@frenchfalse\babel@englishfalse\babel@germantrue}
\ExecuteOptions{french}
\ProcessOptions
%% end of Option zone
\ifbabel@frenchtrue
\RequirePackage[french]{babel}
\fi
\ifbabel@englishtrue
\RequirePackage[english]{babel}
\fi
\ifbabel@germantrue
\RequirePackage[german]{babel}
\fi
\endinput
Here is the .tex
file to compile :
\documentclass[report]
\usepackage[T1]{fontenc}
\usepackage[UTF8]{inputenc}
\usepackage{failedpackage}
\begin{document}
Bonjour TeX.StackExchange !
\end{document}
And here is the .log document : http://paf.im/8a8tc
Well I guess the problem is caused by the fact that the compiler treats the conditional statements (e.g. \ifbabel@englishtrue
) as undefined, but they have been defined right at the beginning of the .sty
!
I don't understand.
Thanks in advance for your help.
\documentclass[report]
-- it must read\documentclass{report}
and the\ifbabel@....
conditionals must go withouttrue
\RequirePackageWithOptions
commandalways loads the required package with exactly the same option list as that being used by the current class or package