# Will LaTeX work on any TeX?

As I understand it, `latex` is simply a macro package for `tex`, as in `tex` the program, not the format. (Again, weird, but I understand LaTeX to be a format of TeX.)

Does this imply that LaTeX the format can be applied to any TeX engine?

Assuming the positive, how are XeLaTeX and LuaLaTeX related to LaTeX, seeing as they build on their respective engines, XeTeX and LuaTeX?

If one were to build another `tex`, assuming it passes the TRIP test, could LaTeX be applied to it?

-
– Martin Schröder Jul 26 '13 at 8:05

The currently LaTeX2e kernel (`latex.ltx`) does not contain any use of primitives other than those provided by Knuth in TeX. Indeed, if you read the code there are explicit steps taken to support TeX 2 (the 7-bit version), even though TeX 3 ('TeX90') was released in 1990. As such, the kernel itself will work with any TeX implementation that passes the TRIP test.

However, there is an important proviso to that. Building a format needs more than just `latex.ltx`, and in particular it needs hyphenation patterns. On my system (TeX Live 2013), trying to build a format file without the e-TeX extensions fails as at least one of the hyphenation files uses `\numexpr` (`texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-ka.tex`). As the hyphenation patterns are not part of the format, you can get around this.

In terms of XeLaTeX and LuaLaTeX, these are very close to the 'standard' LaTeX format. As these engines use UTF-8 input, there are some adjustments which are more-or-less essential in terms of set up (category codes, etc.), which is therefore done in the format-building process. LuaLaTeX's format set up also enables the extra primitives it provides (they don't get activated 'out of the box'). In both cases, these adjustments are needed as `latex.ltx` was designed before XeTeX or LuaTeX were released, and it is a most sensible to make the adjustment as part of the format-building system.

It's worth noting that the LaTeX3 packages (`expl3`, etc.) have tougher requirements. As well as the e-TeX extensions, `\pdfstrcmp` or equivalent functionality is required. Currently, the engines which meet these requirements are

• pdfTeX v1.30 or later
• XeTeX v0.9994 or later
• LuaTeX v0.40 or later
-
What's the TRIP test? – clemens Jul 25 '13 at 19:28
@cgnieder The TRIP test is what Knuth uses to test TeX. If code passes the TRIP test, it is TeX :-) – Joseph Wright Jul 25 '13 at 19:29
Thanks. I also just found `texdoc tripman` :) – clemens Jul 25 '13 at 19:38
@cgnieder: you literally have to take a TRIP. `:)` – Paulo Cereda Jul 25 '13 at 19:46

While it is current that latex.ltx (the file that is used to build the format for LaTeX2e) does not rely on any primitives other than those of a vanilla TeX engine that passes the TRIP test, the LaTeX Project has announced several years back that the expectation is that LaTeX(2e) is run on a system with e-TeX extensions being enabled. This announcement is in one of the ltnews documents that list all important release changes.

As Joseph mentioned in his answer one area where this shows are hyphenation files, but there are also LaTeX packages that started to use these extensions.

Thus the answer to the question is, yes, LaTeX runs on any vanilla TeX engine but there may be some restrictions if it is one of the few systems that do not support e-TeX or have the e-TeX extensions not enabled by default.

-
Is e-TeX similar to LaTeX in that it is a collection of TeX macros, or is it a separate program I should take a look at? – Sean Allred Jul 26 '13 at 20:10
@SeanAllred e-TeX is a set of new primitives added to those provided by Knuth's TeX and developed by the NTS team. See for example Who doesn't use e-TeX? and What are benefits of e-TeX for LaTeX users? for more. – Joseph Wright Jul 26 '13 at 20:28