TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm interested in the general application architecture, how it hangs together. I know it was originally written by Knuth, and it's clear others can write plugin packages to achieve certain things, but what is the overall application structure? How does it work? What are packages written in? What do they conform to?


share|improve this question
LaTeX was originally written by Leslie Lamport. Knuth wrote TeX and LaTeX is essentially a set of macros written in TeX. – Caramdir Sep 19 '10 at 16:30
Those voting to close, could you please leave a reason why you think the question should be closed? – Juan A. Navarro Sep 21 '10 at 12:49
@flesh: Please consider accepting one answer now. Thanks. – Martin Scharrer Jul 1 '11 at 11:24

Briefly, LaTeX consists of several layers. (Those who were actually involved in LaTeX's development, please feel free to correct me.)

The lowest layer is the three hundred or so TeX primitives such as \hbox or \vskip.

On top of this, there is the LaTeX kernel. This is a set of macros such as \documentclass, \usepackage, or \begin. The source of the kernel is documented in the source2e document.

Each document written in LaTeX begins (more or less) with \documentclass{foo} which loads the file foo.cls, for example article.cls or book.cls. This file is another set of macros, this time written using a combination of TeX primitives and macros from the LaTeX kernel. These class files can also load another class to extend it or modify the macros from that class. It can also load packages which are up next.

LaTeX packages—that is, files ending in .sty (and their related files)—are additional sets of macros written using any combination of macros from lower levels. Some are specific to particular document classes, others are more general. These packages can be loaded using \usepackage from user documents, or \RequirePackage from classes and other packages.

At the highest level, the users' documents use a class file and optionally packages. As I'm sure you're aware, these documents contain macros written using any combination of TeX primitives and class- and package-defined macros as well as the prose, verse, and mathematics to be typeset.

There is a lot more detail that one could go into regarding things like fonts and class and package options, but this isn't so "brief" after all.

One final point, Knuth wrote TeX as well as the plain TeX macro package—a set of about 600 macros that make typesetting far easier than using just TeX's primitives. LaTeX was originally written by Leslie Lamport. LaTeX 2e—the most recent version—was also written by Johannes Braams, David Carlisle, Alan Jeffrey, Frank Mittelbach, Chris Rowley, and Rainer Schöpf.

share|improve this answer
Brilliant explanation, thanks – flesh Sep 21 '10 at 12:37

As Dan mentioned, this question is probably too broad for the size of responses available from forums such as this. You asked about the "general application architecture", in which case your question covers the major document classes (book, article, etc.) and perhaps many of the extensional classes and packages that comprise the standard repertoire that LaTeX experts use reflexively in their work.

However, if you can confine your question to the core LaTeX engine architecture, that is, to the layer that sits on TeX and that provides abstractions and services to bolt-on classes and packages, you might consider perusing the documented source code, generally available in source2e.pdf (type texdoc source2e at a command prompt). It's certainly not for the faint-hearted but, even if your TeX programming skills are not yet strong, the documentation and the document structure will provide a good sense of things to any reasonably competent systems architect.

share|improve this answer
@flesh, on reflection it's fairly clear that you weren't interested in the systems architecture. In which case, follow up on Dan's answer by checking out the wiki pages he suggested. I'll let my answer stand for a while, just in case you have some interest in it. :) – Geoffrey Jones Sep 19 '10 at 18:06
No, that's exactly what I am interested in. So if I understand it, Tex is a language, and LaTex is an implementation? – flesh Sep 19 '10 at 19:12
@flesh: No. TeX is a macro language. LaTeX is a set of macros written in TeX. pdfTeX would be an implementation of TeX. – TH. Sep 19 '10 at 22:06
@flesh. What TH. said. In systems terms, TeX is a kernel (for our purposes anyway; I'm sure that to core TeX programmers, there's something in the TeX engine that to them is the true kernel). LaTeX is a TeX abstraction, specified in both the TeX and LaTeX languages. As such, LaTeX is both a reference language (extensional to the TeX language) and, under the good grace of some actual TeX implementation (e.g., pdftex), an implementation of its own (e.g., pdflatex). There are two concepts here: abstraction layer/level and implementation. – Geoffrey Jones Sep 20 '10 at 5:04
@Geoffry Jones: Actually, pdflatex is not an implementation of latex; it's just an executable name. In most TeX systems, it will be byte-for-byte identical to pdftex, and the name is used to determine which pre-parsed "format" to load. (It might be possible for the formats to be baked into the various executables in some TeX systems, though.) In fact, if I'm not mistaken, generally tex and latex are identical to pdftex and pdflatex, differing only in that their associated format files default to DVI output rather than PDF output. – SamB Sep 22 '10 at 23:28

This question is not clear enough to motivate many answers. You might wish to start reading at http://en.wikipedia.org/wiki/LaTeX

share|improve this answer

If you want to learn about the basic typesetting engine TeX, you can read The TeXbook, which is essentially the manual, or even TeX the Program, a book consisting primarily of the the result of running weave on TeX's own source code (which is not to say it isn't quite well-written; the program was written to be presented in this manner from the outset). Bibliographic details for both books are available on Knuth's Computers and Typesetting page.

share|improve this answer

You have TeX which is a typesetting engine, the real binary program that you invoke when you typeset a *TeX document. TeX has a macro programming language that is used to write "packages" i.e. collection of macros to simplify certain tasks. LaTeX is a macro package written in TeX macros and is set to achieve certain goals (other common macro package are plain TeX which was written by Knuth himself, Texinfo the official GNU documentation system, and ConTeXt which is general purpose typesetting system).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.