[Tex/LaTex] Frequently loaded packages: Differences between XeLaTeX and LuaLaTeX

luatexpackagesxetex

Adding the missing member to pdfLaTeX vs. XeLaTeX and pdfLaTeX vs. LuaLaTeX, here's the last of the big three: XeLaTeX vs. LuaLaTeX.

Where would a typical template for XeLaTeX differ from one for LuaLaTeX? Two areas coming to my mind in which it would be nice to get some detailed information on what's advisable to use, or what's currently usable to which degree with which compiler are:

  1. microtype
  2. babel vs. polyglossia

Since I don't expect there to be too many packages to list here, it might also sense to mention which packages both XeLaTeX and LuaLaTeX users typically make use of, but not pdfLaTeX users, i.e. the common denominator (?) of the other two questions in the "trinity".

For the general differentiation between XeLaTeX and LuaLaTeX see Differences between LuaTeX, ConTeXt and XeTeX. Also related: Considerations when migrating from XeTeX to LuaTeX?

Best Answer

While I’m no expert in either XeLaTeX or LuaLaTeX, I’ve used both a bit, so I’ll try to write up some things that I’ve noticed in the “front-end” superficial user level.

fontspec

... is the standard way of using fonts with both engines. I haven’t noticed remarkable differences in the outcome or font selection, but according to the comments to this question, there seem to be some.

This means, of course, that neither inputenc nor fontenc should be used. Do make sure to save your .tex file in UTF-8.

microtype

Version 2.5 from 2013-03-13 seems to have improved XeLaTeX support a lot. For LuaLaTeX (and pdfLaTeX), protrusion and expansion are supported; for XeLaTeX it’s only protrusion. Since microtype typically works great without further configuration, you can simply load it for any of the engines.

babel/polyglossia

polyglossia only works with XeLaTeX. A minimal setup of babel works with both engines (I think a recent update also included some improvements for XeLaTeX, is that right?), but the package description on CTAN still says: “Users of XeTeX are ad­vised to use polyglos­sia rather than ba­bel.” Hence, I’d follow that advice and use babel with LuaLaTeX (and pdfLaTeX), but polyglossia with XeLaTeX. That’s certainly the way it used to be.

xunicode

On up-to-date systems, this package should not be necessary at all – that seems to be the verdict here on tex.sx. If anywhere, it should only be used with XeLaTeX; in fact, it produces an error message in LuaLaTeX (unless it’s loaded after fontspec).

LuaLaTeX-only packages

While there probably are some packages specifically tailored for XeLaTeX, I would assume there are (and will be) many more for LuaLaTeX, making use of the scripting language Lua being tightly tied into the engine. Two that I have used so far are Patrick’s lua-check-hyphen, enabling you to easily check all hyphenations that occur in your document, and Mico’s selnolig (announcement on meta), which automatically suppresses typographically undesirable ligatures for English and German, based on an extensive pattern list. (Check it out.)