478

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.)

Konrad Rudolph
  • 39,394
  • 22
  • 107
  • 160
  • 8
    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
  • 10
    @ajray: Xetex wins the usability contest, I think. Fonts just work. – Charles Stewart Aug 12 '10 at 13:21
  • 4
    @ajray if it's just unicode characters you want, wouldn't \usepackage[utf8]{inputenc} work? – Seamus Nov 18 '10 at 17:57
  • 5
    @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
  • 4
    @CharlesStewart: With LuaLaTeX they also just work. Same with ConTeXt MkIV. – Martin Schröder Sep 28 '11 at 12:12
  • 1
    Is there a complete implementation of LaTex in a more user-friendly language? E.g. Python, Javascript, etc? Thanks – Honza Pokorny Jan 17 '12 at 18:10
  • 1
    @HonzaPokorny: No there is not. LaTeX is a TeX format and simply needs TeX. There was once a project to implement TeX (not LaTeX) with Java but AFAIK it got never finished. – Martin Scharrer Jan 23 '13 at 06:46
  • @MartinScharrer NTS was completed for all I know. It was just judged unusable because hundreds of times slower than the original implementation of TeX. What was then abandoned was plans to extend it with additional features. – Arthur Reutenauer Aug 23 '15 at 03:05
  • 2
    @CharlesStewart Today, XeTeX loses this contest because math font just don't work. – Henri Menke Aug 08 '16 at 08:22
  • @HenriMenke For completeness, that bug was fixed a few months later. – Hashim Aziz Mar 23 '20 at 22:29
  • @Hashim That particular problem seems to have been fixed, but fontdimens for math fonts in XeTeX are still incorrect, so math typesetting with XeTeX remains broken. https://sourceforge.net/p/xetex/bugs/87/ – Henri Menke Mar 23 '20 at 22:41

5 Answers5

391

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.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • 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 08:50
  • 2
    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
  • 4
    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 09 '10 at 09:20
  • 28
    Here is a nice explanation of the levels of TeX. – Martin Schröder Sep 28 '11 at 12:13
  • 6
    This answer is now three years old. Have things changed? – Raphael Aug 12 '13 at 14:06
  • 4
    @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
  • @JosephWright I'd like to ask the same as Raphael. As of today, is Lua` still in beta? – Mario S. E. Oct 11 '13 at 06:44
  • @MarioS.E. Version remains below 1.0, so yes. (At time of writing, release version is 0.76.0.) – Joseph Wright Oct 11 '13 at 07:19
  • I'm writing a novel using Focuswriter, creating chapter files (ascii UTF8 text files WITHOUT LaTeX markup) It converts sideless quotes [ " quote " ] into left and right side quotes automatically. [ “ left right ” ]

    A master file with \include{chapter} will have LaTeX code. Does the UTF8 feature of XeTeX mean that my leftside and rightside quotes will automatically be read without having to use double marks [ quote ' ' ]

    If so, this will save a LOT of editing in my chapter files, since there's a good bit of dialogue.

    – user12711 Apr 23 '15 at 18:53
  • 1
    @user12711 Certainly possible, both with XeTeX and indeed with pdfTeX (8-bit). That would be a new question, of course: please post (although any decent editor will make short work of the change). – Joseph Wright Apr 23 '15 at 18:57
  • 1
    It is now early 2017, and there have been many changes. I'd love to see this re-visited. I use LuaLaTeX exclusively (TeXLive 2016), and cannot use XeTeX for my specific application (which writes immediate to PDF). Yet I notice that current questions on this site almost always concern XeTeX, and are not necessarily from experienced users. Also: LuaLaTeX does double quotes, just like XeTeX. –  Apr 04 '17 at 14:47
  • 1
    @RobtA I'm not sure what I could change substantively today. XeTeX and LuaTeX both continue to have advantages, depending on the area one is working in. Improvements in LuaTeX and in luaotfload (the font shaper used by LuaLaTeX) mean they are 'closer together', but HarfBuzz (used by XeTeX) still has some advantages in this regard. – Joseph Wright Apr 04 '17 at 16:05
  • @RobtA Double quote ligatures are a feature of luaotfload not of LuaTeX itself: try ConTeXt MkIV for a different approach! (It uses \quote for logical mark up of quotations so does not use TeX-like ligatures in this area.) – Joseph Wright Apr 04 '17 at 16:06
  • @MartinSchröder LaTeX seems to work with TeX, pdfTeX, XeTeX, and LuaTeX, but ConTeXt Mark IV only works with LuaTeX? – Franklin Yu Jan 02 '18 at 00:06
  • @MarioS.E. LuaTeX has been stable since 2016, but this answer is still true… – Franklin Yu Jan 02 '18 at 00:25
  • @JosephWright Another six years since your last comment: any updated thoughts today on the choice LuaTeX vs. XeTeX vs. pdfTeX and the state of each of them? (Also, would pdfTeX still have most potential in terms of typography aesthetics due to strongest microtyping support?) – Carl Sep 21 '23 at 19:25
107

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.

Konrad Rudolph
  • 39,394
  • 22
  • 107
  • 160
  • 4
    Luatex supports fontspec, although it's not trouble free yet. – Charles Stewart Jul 27 '10 at 08:52
  • 2
    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, http://stackoverflow.com/questions/414179/what-are-the-relative-merits-of-pdflatex – 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
  • 1
    @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 07:58
62

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.

Taco Hoekwater
  • 13,724
  • 43
  • 67
  • 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
  • 2
    luasocket has an easy interface for downloading http files, see http://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 08:31
53

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.

helcim
  • 1,548
  • 4
    +1 for the link. I have been curious about ConTeXt for a while- this paper looks like good reading. – Sharpie Aug 03 '10 at 21:53
  • 11
    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
  • 6
    @CharlesStewart: I just came across this question and saw your comment here. I actually just made a family tree a couple days ago... [http://tex.stackexchange.com/questions/42594/tex-family-tree-with-timeline] – Todd Lehman Jan 30 '12 at 03:40
26

Each of them is variation/implementation of TeX. LuaTeX is really just like Knuth's original TeX system (with LaTeX) but is using Lua as its embedded scripting engine, 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.

mcepl
  • 159
Quadrescence
  • 1,550
  • 11
  • 9
  • 8
    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 03 '10 at 21:52
  • 2
    @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
  • 9
    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 01:30