# British hyphenation with either xelatex or lualatex

For several reasons, I am working on a source file that should be compilable by either xelatex or lualatex. I would like British hyphenation for the text and am using csquotes and biblatex with british options.

On the XeTeX mailing list two things were mentioned:

(a) Use polyglossia, not babel with xelatex;

(b) polyglossia is incompatible with lualatex at present; use babel instead.

I show below a sample file with my question and my present setup.

\documentclass[12pt,a4paper]{memoir}
%
\usepackage{fontspec}
\setmainfont{Minion Pro}
%
% We want to compile with either xelatex or lualatex
% The former requires polyglossia for british hyphenation
% The latter requires bable for british hyphenation
%
% Ideally something like (unsure if this is correct)
%
% \ifxetex
%       \usepackage{polyglossia}
%       \setmainlanguage[variant=british]{english}
%
% \ifluatex
%       usepackage[british]{babel}
%
% should work but I do not know the correct syntax for it.
%
% My workaround is:
%
\makeatletter
\language=\l@british
\makeatother
%
% which works but is inelegant in a *LaTeX source file.
%
\usepackage[backend=biber,babel=none,date=iso8601,urldate=iso8601,language=british,refsection=chapter,sorting=none,style=numeric-comp,hyperref=auto]{biblatex}
\usepackage[english=british]{csquotes}
\begin{document}
Try some hyphenation, some \enquote{quotations}, and some references to see if everything works.
\end{document}


Any suggestions to make hyphenation and other language features like date work consistently across both xelatex and lualatex is most welcome.

-
Actually you can use babel with XeLaTeX, as long as you don't start trying it with exotic languages. English (both British and American) should work without any glitch. –  egreg Nov 4 '11 at 18:29
@egreg: Thanks. I was not aware of that. –  chandra Nov 5 '11 at 19:45

While polyglossia is widely recommended for XeLaTeX usage, babel can still be used for languages that need only the Latin alphabet.

-
\usepackage{ifluatex,ifxetex}
\ifxetex
\usepackage{polyglossia}
\setmainlanguage[variant=british]{english}
\else\ifluatex
\usepackage[british]{babel}
\fi\fi


This loads polyglossia for xetex and babel for luatex.

-
I find that the above works if I compile with lualatex and later with xelatex. However, if I first compile with xelatex and later with lualatex it gives me a babel error. I then need to delete the .aux file before compiling with lualatex, and all goes well. I point this out not because it is serious but because one needs to remember to delete the .aux file. –  chandra Nov 6 '11 at 14:44
That's it! Indeed .aux files should be cleaned when you change compiler. I don't know remedy to copy with this problem. –  Igor Kotelnikov Nov 6 '11 at 15:12
@Igor it is due to the multi-pass nature of LaTeX. Thus, it is probably not to be solved, except for the deletion of temporary files. Which is probably a wise thing to do anyway when switching environment, as you mention. –  Legolas Mar 21 '12 at 10:52