[Tex/LaTex] If LaTeX is only a macro package, why does it have its own executable

contextlatex-miscmacrostex-core

From other answers on this site and the FAQ of the TeX User Group my understanding is that:

  1. TeX is the original typesetting program, written by Knuth
  2. Omega, eTeX, pdfTeX, XeTeX, LuaTeX are engines. They are variations of the original TeX program, written in different languages, designed to give almost the same output for the same input as the original TeX, but with great variations in the inner workings and slight variations in the interface that make possible for the user to access the inner workings
  3. LaTeX and ConTeXt are macro packages. They are like libraries of TeX macros. While LaTeX works on all the engines, the last version of ConTeXt (Mark IV) works only with LuaTex, because it uses many features exclusive of this engine.

What I do not understand is why both LaTeX and ConTeXt require their own executable. Isn't it possible just to include in the TeX source files where one wishes to use LaTeX just the definitions of the LaTeX macros (maybe with an \include directive)?

Best Answer

It certainly is possible to use LaTeX just as a file to be read by TeX, but it's not common. There are at least a couple of reasons. TeX is designed to allow a set of macros ('format') to be read then dumped 'as is' by 'IniTeX'. When you do

tex <file>

you are running TeX the program with Knuth's plain format, rather than a completely un-initiallised 'VirTeX' ('virgin TeX'). LaTeX cannot be loaded once any other format has been, as there is overlap between names in ways that are not always compatible. You can run TeX with and load the LaTeX kernel using IniTeX

tex -ini "\input latex.ltx"

(on my system, at least: the details vary a bit). However, doing this means that TeX has to process all of the LaTeX kernel before doing anything 'useful'. It's therefore easier to load the pre-built format (memory dump):

tex "&latex"

(The & syntax is general: tex "&<format-name>" loads whatever format is requested.)

The binaries you see on a modern TeX system are very much like wrapper around this process, although they run pdfTeX rather than Knuth's TeX. There are some 'details' to this, but the basic idea is the same.

ConTeXt is a little different as unlike LaTeX it does the multiple TeX run stuff itself. As such context is more than a wrapper: it's a complex script. You can run ConTeXt as a format, in the same way as you can for LaTeX, but this is even less useful than it is in the LaTeX case.