# Differences between LuaTeX, ConTeXt and XeTeX

I’m interested in the differences and commonalities between the “new” (La)TeX processors:

Personally, I’ve only used XeTeX so far and without having the time to try out all three systems, I’m having a surprisingly hard time setting them off from one each other.

As I understand it, these systems are actually very different in some regards. So I’m explicitly asking for strengths and weaknesses in every-day use (whatever that is), rather than very special scenarios.

(I’ve already asked a similar question on Super User some time ago.)

-
I love XeTeX just because I can add unicode characters in my editor, instead of having to /command all of them. –  machinaut Jul 26 '10 at 19:40
@ajray: Xetex wins the usability contest, I think. Fonts just work. –  Charles Stewart Aug 12 '10 at 13:21
@ajray if it's just unicode characters you want, wouldn't `\usepackage[utf8]{inputenc}` work? –  Seamus Nov 18 '10 at 17:57
@Seamus: The `inputenc` package unfortunately is very incomplete and in some circumstances it doesn’t work at all (e.g. in combination with fancyvrb, since their verbatim parsing somehow disables UTF-8 character code parsing). –  Konrad Rudolph Nov 18 '10 at 20:11
@CharlesStewart: With LuaLaTeX they also just work. Same with ConTeXt MkIV. –  Martin Schröder Sep 28 '11 at 12:12

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). LuaTeX is an exciting idea, but XeTeX is more mature and I think at the moment the easier choice for end users. (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.

-
And Context-2 is a regular format, which works with any Tex that supports the right Tex extensions, including Xetex. –  Charles Stewart Jul 27 '10 at 8:50
Well, most ConTeXt users use texexec, which is a bit more than just a TeX format. However, you are right that ConTeXt MkII can be used in that way. –  Joseph Wright Jul 27 '10 at 13:13
You're right, but texexec is a bit like a make file. BTW, texexec is Context-2 only: Context-4 is invoked with `context` which is another name for `luatex`. Luatex handles everything that texexec used to. I'm guessing that, by now, most Context users use MkIV. –  Charles Stewart Aug 9 '10 at 9:20
Here is a nice explanation of the levels of TeX. –  Martin Schröder Sep 28 '11 at 12:13
@Raphael Not really in a substantive way. LuaTeX is still formally beta (v0.76) and XeTeX has improved in terms of its font shaper (the part that allows for complex font operations). For many 'end user' applications XeTeX and LuaTeX are both suitable. –  Joseph Wright Aug 12 '13 at 15:34

Each of them is variation/implementation of TeX. LuaTeX is really just like Knuth's original TeX system (with LaTeX) but is implemented in Lua, which some find to be easier to handle and extend. I believe TeXLive is officially switching to use LuaTeX from now on.

XeTeX has especially useful font capabilities. It is essentially standard TeX but the ability to use OpenType and TrueType (instead of Type 1) fonts instead of the confusing setup in standard TeX. If you've ever had to install a font with standard TeX, or even make your own, you know it's a pain, even with `fontinst`.

ConTeXt is a different approach to TeX. ConTeXt is like LaTeX, but with different ideas of how thing should work. ConTeXt attempts to make things easier, especially typographical issues. Colors, figures, and changing document structure is more straightforward in this system.

Disclaimer: I am no expert on these systems. I personally use just standard LaTeX.

-
I think you mean OpenType/TrueType fonts instead of Type 1, which is what TeX is normally using, right? –  Konrad Rudolph Jul 26 '10 at 19:50
@Konrad Rudolph: Yes, you are correct. I was thinking of purely bitmapped fonts which is what METAFONT generates, and Type1 can be bitmap. I'll correct. –  Quadrescence Jul 26 '10 at 20:19
I thought LuaTeX was implemented in C (as opposed to the original Pascal implementation of TeX). The Lua functionality comes from having the Lua interpreter embedded within the program. –  Sharpie Aug 3 '10 at 21:52
@Sharpie: Right. What Luatex provides is a family of hooks into the Tex engine that can be leveraged in format files to provide functionality that the Tex primitives can't. –  Charles Stewart Aug 12 '10 at 13:19
TeX Live is not switching to use LuaTeX right now, and it's not sure it ever will. TeX Live provides pdfTeX, XeTeX and LuaTeX, but for the foreseeable future, the "latex" command will continue to invoke the pdfTeX engine. –  mpg Oct 31 '10 at 1:30

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.

-
Luatex supports fontspec, although it's not trouble free yet. –  Charles Stewart Jul 27 '10 at 8:52
Another drawback: if you prefer to work with Postscript specials, you are forced to work with XDVI rather than DVI, which has much poorer tool support. Some people do prefer the DVI toolchain, e.g., Norman Ramsey, stackoverflow.com/questions/414179/… –  Charles Stewart Aug 12 '10 at 13:26
Is there any indication of when we can expect LuaTeX to have full microtypography? Any time now/years/possibly someday? i.e. is it worth waiting for before getting used to one engine? –  Canageek Sep 27 '11 at 22:15
@Canageek LuaTeX is a different matter entirely. It has supported the major features of `microtype` for some time now. Even XeTeX now supports the main feature, protrusion. –  Konrad Rudolph Sep 28 '11 at 7:58

The choice is slightly wrong. First two are TeX engines while ConTeXt is a macro package and as such should be compared with LaTeX (in fact you can use both XeTeX and luatex in ConTeXt, although using luatex is definitely preferred). The best comparison of differences between LaTeX and ConTeXt can be found in the article by Berend de Boer LaTeX in proper ConTeXt. To put it in rather simplistic terms: ConTeXt attempts at giving cleaner interface to control typography of the document while retaining LaTeX's structure-oriented approach.

-
+1 for the link. I have been curious about ConTeXt for a while- this paper looks like good reading. –  Sharpie Aug 3 '10 at 21:53
It's worth noting that the Xetex, Pdftex, and Luatex engines, are not children, but grandchildren of Knuth's Tex program, all being descended from the Web2c translation of Knuth's Tex. Actually, I guess that Luatex is a great-grandchild, being a child of Pdftex. I wonder if some TUG-boat article has a nice family tree in it? –  Charles Stewart Aug 12 '10 at 13:16
@CharlesStewart: I just came across this question and saw your comment here. I actually just made a family tree a couple days ago... [tex.stackexchange.com/questions/42594/… –  Todd Lehman Jan 30 '12 at 3:40

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.

-
If want to use HTTP for fetching images (for instance using Pachube's parametrised graphs) - can I import an HTTP library and output the image into a file, the do \includegraphics on that file? or may be I'll have to use the luasocket and talk raw HTTP to it? –  errordeveloper Jan 17 '12 at 20:10
luasocket has an easy interface for downloading http files, see w3.impa.br/~diego/software/luasocket/http.html . I do not know how to connect that to \includegraphics , but it should not be that hard –  Taco Hoekwater Jan 27 '12 at 8:31