I just asked about Documentation on the Algorithms or Techniques LaTeX uses for Text Layout, which lead to Alternatives to LaTeX which pointed out some tools such as ConTeXt. I also have heard of LuaTeX, MikTex, TeX Live, and others.

I am not familiar with how these different "LaTeX tools" work, which is what this question is about. I am wondering if they actually implement TeX from scratch. That is, they somehow read the research papers and implemented all the algorithms without resorting to some standard / central TeX library. By standard / central TeX library I mean some central code repository that implements all the algorithms from the research papers. If all these tools are all implementing the research from scratch then that would be a useful learning tool.

If the tools I listed (and others similar) are just wrappers around a central TeX library, then wondering what that central library is. I have seen https://github.com/latex3/latex2e, but given that LaTeX and TeX are different, I am not sure if that would be considered tex-core. This question Where is source code of TeX, LuateX, pdfTeX leads to CTAN TeX (also here, looks like it's written in WEB, and how to compile it), but not sure if everything is using that. If instead there are multiple different implementations of the TeX research, that would be helpful to know as well.

  • 3
    Different categories: (1) Programs (binaries, software applications): TeX, eTeX, pdfTeX, XeTeX, LuaTeX. Originally Knuth wrote (current version of) TeX in WEB (≈ Pascal + macros), and the other programs take that code (LuaTeX translated to C first) and extend it. (2) Macro packages (aka formats): LaTeX, ConTeXt — these are basically certain “input” you can give to the previously mentioned programs, to make the life of the user easier (e.g. automatic numbering or cross-references). (3) TeX distributions: MikTeX, TeX Live. These are convenient ways to “install everything”. Jul 23, 2018 at 4:32

1 Answer 1


You are conflating things of different kinds. In addition, I think you may be making a category mistake, although I'm not certain of this.

  • MikTeX and TeX Live are distributions of TeX in the sense of 'everything' or, more accurately 'most of it'. If you install them, you get TeX, LuaTeX, ConTeXt, XeTeX, LaTeX, a bunch of packages, scripts, additional tools etc.

  • TeX, pdfTeX, LuaTeX, XeTeX and ConTeXt are engines. These turn .tex files into processed documents: DVI or PDF.

  • plain, LaTeX and ConTeXt are formats. They are built up from the primitives provided by core TeX. If people say they are using TeX, as opposed to LaTeX, they usually mean they are using the plain format. But this is still a format built on top of the core, just as the other formats are.

    This list is not comprehensive. There are many formats and you can make your own quite easily. But these are probably the best known, at least in the West.

    Core TeX and the plain format are described in The TeX Book. LaTeX is described in Lamport's book and in the documentation provided with the format. Using the LaTeX format, as I understand it, is equivalent to loading latex.ltx. Using plain is equivalent to loading a file containing the macros defined by that format.

ConTeXt is both an engine and a format.

Otherwise, you have

  • format + engine -> binary or binary-by-name

  • plain + TeX -> tex

  • LaTeX + TeX -> latex
  • plain + pdfTeX -> pdftex
  • LaTeX + pdfTeX -> pdflatex
  • plain + LuaTeX -> luatex
  • LaTeX + LuaTeX -> lualatex
  • plain + XeTeX -> xetex
  • LaTeX + XeTeX -> xelatex

A format is just a pre-compiled bunch of code which you could load, but it would be slower and less convenient.

Many of the above binaries are binaries-by-name, by which I mean that two different names invoke the same binary, whose behaviour depends on the invoking name.

lrwxrwxrwx 1 texlive texlive    6 Tach 25  2016 ../bin/x86_64-linux/latex -> pdftex*
lrwxrwxrwx 1 texlive texlive    6 Tach 25  2016 ../bin/x86_64-linux/lualatex -> luatex*
-rwxr-xr-x 1 texlive texlive 8.4M Ebr   2 18:10 ../bin/x86_64-linux/luatex*
lrwxrwxrwx 1 texlive texlive    6 Tach 25  2016 ../bin/x86_64-linux/pdflatex -> pdftex*
-rwxr-xr-x 1 texlive texlive 2.1M Maw  26 23:02 ../bin/x86_64-linux/pdftex*
-rwxr-xr-x 1 texlive texlive 371K Maw  21 21:47 ../bin/x86_64-linux/tex*
lrwxrwxrwx 1 texlive texlive    5 Tach 25  2016 ../bin/x86_64-linux/xelatex -> xetex*
-rwxr-xr-x 1 texlive texlive  23M Ebr   2 18:10 ../bin/x86_64-linux/xetex*

As you can see, invoking pdflatex invokes the same binary as does pdftex. The difference is that the former results in the use of an option specifying the LaTeX format.

As was said in answer to your previous question, The TeX Book and the source code for TeX are the place to look. The rest is just elaboration.

The LaTeX 3 project concerns development of the third major version of the LaTeX format. Currently, the version is 2e, though some parts of the L3 project can currently be used on top of 2e. Like 2.09 and 2e and (presumably) version 1, this is 'just' a format on top of TeX. It is not different from TeX in the sense of being an alternative. It is different from TeX in the same way that a house is different from its foundations.

The CTAN page you linked includes links to some extensions e.g. eTeX and pdfTeX. So you could look at e.g. https://tug.org/svn/pdftex/branches/stable, but then you are looking at extended versions and not a bare-bones version i.e. if you want just the core, look at the source for the core. If you want to see how it has been re-implemented and extended, look at the source for eTeX or pdfTeX or LuaTeX or whatever.

  • So the LaTeX repo won't have the source code for the layout and core text algorithms like found in The TeX Book. "MikTeX and TeX Live are distributions of TeX" wondering if this means they have reimplemented the source code from scratch (like in a different programming language from WEB, such as in C or Lua or something), or if they are just bundling that WEB code (compiled into a binary somehow).
    – Lance
    Jul 23, 2018 at 3:39
  • 1
    Yes. No. They are distributions in the sense that Debian and Fedora are distributions of the Linux kernel. They don't reimplement the code of the kernel. They are all drawing from the same code base.
    – cfr
    Jul 23, 2018 at 3:42
  • 1
    To repeat: LaTeX is 'just' a format. That's true of every version of LaTeX, including version 3. (That is, unless the development team take it into their heads to rewrite TeX before they actually publish version 3, but, if so, that is certainly not planned now.)
    – cfr
    Jul 23, 2018 at 3:44
  • 2
    No. The kernel of all Linux distributions is the same except for differences in version, patches applied or configuration options. They all take code from the same development tree. This is why bug reports go upstream and not to your Linux distro. The distros just do what you could do: download the source for the kernel, configure it, apply any patches you want and compile it. The distributions may differ in the other stuff they provide, but the kernel is standard.
    – cfr
    Jul 23, 2018 at 3:48
  • 1
    No. There is backslash stuff in the core, too. Those are primitives. \section is a macro. But it is not a primitive. LaTeX doesn't add primitives. (Some extensions of TeX, such as pdfTeX, add primitives, in addition to providing all the core ones.) Note that plain and ConTeXt add macros, too. Backslashes aren't LaTeX-specific.
    – cfr
    Jul 23, 2018 at 3:50

Not the answer you're looking for? Browse other questions tagged .