Differences between LuaTeX, ConTeXt and XeTeX

Both LuaTeX and XeTeX are UTF-8 engines for processing TeX documents. This means that the input (.tex files) can contain characters that with pdfTeX are difficult to use directly. Both can also use system fonts, again in contrast to pdfTeX. However, the two are very different in approach.

XeTeX uses system-specific libraries to work. This means that it is very easy to use 'out of the box' for loading system fonts and other UTF-8 tasks. Indeed, it was written for this purpose: supporting languages, etc., that traditional TeX struggles with. This makes for an easy to use engine for end users, particularly if you use the fontspec package on LaTeX. However, because things are 'farmed out' to the OS, there is a trade-off in flexibility terms.

In contrast, LuaTeX has bigger aims. The idea is to add a scripting language (Lua) to TeX, and to open up the internals of TeX to this language. The result is that a lot is possible, but it has to be programmed in. There is growing LaTeX support for LuaTeX: fontspec v2 supports it, and new packages are being written to use more of the new features.

At the moment, I'd use XeTeX for UTF-8 and font support, unless I was after particular effects that only LuaTeX does well (Arabic typography is a particular challenge). The choice btween XeTeX and LuaTeX is 'tight': both have advantages depending on your exact requirements. (I'm on the LaTeX kernel team, so as a programmer I'm very keen on exploiting LuaTeX.)

ConTeXt is not an engine, and so is in a slightly different place here. ConTeXt is a format for TeX, like LaTeX, but is newer and much larger. ConTeXt Mark IV is a LuaTeX-only implementation. The people behind ConTeXt are very active in developing LuaTeX, and are using the new features to extend TeX and what ConTeXt can do. I've already pointed out that I'm working on LaTeX, so of course I'd like to see new features in LaTeX do the same. This is something I and the other members of the LaTeX project are working on.


XeTeX basically offers two improvements over the default LaTeX, and has one drawback.

The improvements are:

  • XeTeX supports UTF-8 encoded input by default. In fact, this is the only supported encoding.
  • XeTeX supports TrueType/OpenType fonts directly. This can be harnessed by the powerful fontspec package which makes loading and using installed fonts really easy.
  • Font support goes much further than what most (even professional) editors support. For example, it easily allows access to special font features such as rare ligatures, glyph variants and old style (text style) numbers.

The drawback is:

  • XeTeX does not (yet) support the full feature set of the microtype package, as pdfTeX does. However, the main feature, protrusion, works well.

Furthermore, XeTeX has PDF ouput only; no DVI or PS. I’m not sure if this can be counted as a drawback but YMMV.


Joseph Wright's answer sums up the differences very well, I just want to add that luatex is also a scripting language in its own right: when you run the luatex executable as texlua (or alternatively, run luatex --luaonly) it will behave as a lua script interpreter with a few library additions.

In this mode, no typesetting can be done, but that does not mean it is not useful. For example, as far as I know, this is the only script interpreter with a built-in kpathsea interface. None of the typesetting-related features are exposed, but the other lua functionality in luatex is available to scripts:

  • kpse, for file searching
  • fontloader, to investigate font files
  • mplib, for creating metapost graphics
  • epdf, to investigate pdf files (still experimental)

Also, some useful lua libraries from the internet have been added:

  • luamd5, for checksum calculations
  • luasocket, for network i/o
  • luafilesystem, for disk i/o
  • slnunicode, for unicode string processing
  • luazip, for zipfile input
  • lpeg, for writing parsers

This scripting capability of luatex is used for some of the scripts in TeXLive 2010, and hopefully this more scripts can be replaced in the future.