10

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}
    \setsansfont{Myriad 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.

1
  • 4
    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
    Commented Nov 4, 2011 at 18:29

2 Answers 2

12

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

8
\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.

3
  • 2
    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
    Commented Nov 6, 2011 at 14:44
  • 1
    That's it! Indeed .aux files should be cleaned when you change compiler. I don't know remedy to copy with this problem. Commented Nov 6, 2011 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
    Commented Mar 21, 2012 at 10:52

You must log in to answer this question.

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