23

I occasionally see a statement that plain TeX is not the same as TeX, because plain TeX is already a format.

What is plain TeX, and what is the difference to TeX proper?

Some answers are here (The differences between TeX engines), but I am looking for a definitive summary.

38

The "smallest" possible TeX is what Knuth called "virgin" TeX (TeXbook, p.342): it knows just primitive commands, no macros. Plain TeX is the set of macros (developed by Knuth) which makes TeX usable in everyday life of a typist.

And yes, these days we're using many different sets of macros ... one popular set is of course LaTeX. Plain TeX is, well ... the plainest of these ;-)

Regarding formats (as far as I understand). "Teaching" TeX all the macros (of plain TeX, for example) on each run would take too long (well, at least in the old days). Thus, we do it once for good: we input the definitions and take a snapshot, called a format.


The available commands can be classified into primitive commands and macros. Macros are composite commands built from primitive commands and/or other macros.

The "virgin" TeX knows only the primitive commands. Which primitive commands are known to TeX depends on the particular engine. For example, eTeX has more primitives than the original (Knuth's) TeX; \unexpanded is an example of a new eTeX primitive. Examples of primitive commands: \relax, \def, \halign. (There's about 300 of them.)

Formats (plain TeX, LaTeX, etc.) extend TeX's vocabulary by defining macros. (Actually, packages also do that.) For example, plain TeX defines macros \item, \rm, \newdimen, \loop, etc. (Plain TeX defines about 600 macros. The complete vocabulary of plain TeX has thus about 900 words.)

To check whether a command is primitive or a macro, one can:

  • look into the index of the TeXbook: primitive operations are marked with an asterisk
  • Use (primitive) command \show: \show\cs writes the meaning of \cs to the terminal. If you \show a primitive command, it will simply tell you its "name": \relax=\relax, halign=\halign, etc. In contrast, if you use \show on a macro, you will get its definition, e.g. \newdimen=macro:->\alloc@ 1\dimen \dimendef \insc@unt.

To reiterate, there are two types of commands:

  • primitives (these are the only things that "virgin" TeX knows about)
  • macros ("virgin" TeX knows no macros; macros are defined by formats and packages; formats and packages define only macros)
  • 1
    Thank you. This is a much clearer explanation of "TeX format" than the one given on the The levels of TeX webpage. – Lover of Structure Feb 10 '13 at 7:02
  • 4
    Handy reference on all TeX-core primitives for those who doesn't have The TeXbook: tug.org/utilities/plain/cseq.html#top-ai – yo' Feb 10 '13 at 8:32
  • 4
    Worth noting that VirTeX cannot really typeset anything as it has nothing set in the \output token register, whereas plain has a small but functional output routine. – Joseph Wright Feb 10 '13 at 8:56
  • 1
    Is there any way to invoke "virgin" TeX from the command line? – Lover of Structure Feb 18 '13 at 13:47
  • 1
    It's called initex. – Sašo Živanović Feb 18 '13 at 16:04
5

Just a little note on Saso's answer (hopefully) clearing any inconveniences that may have been stated in the comments on his answer:

  • TeX . Computer Language that is Turing Complete (as capable as any other language eg. C, Java, pyhton, ...). The word 'TeX' is often synonymic used to refer to 'plainTeX'. TeX (the language) is highly specialised as it was aimed to provide a markup language rather than a computer language.

  • plainTeX . so called 'format' of TeX: you run iniTeX (eg. $ tex -ini on linux shell); you define your fonts and macros as you like; you run \dump in iniTeX. This produces a 'format-file' that can be loaded using virTeX to sort of proceed where you left. plainTeX has been provided by Don Knuth himself and is referred to by the word 'TeX'. You can experiment with it by (linux shell again):

    $ tex hereafter some random stuff enganged by TeX is spawning
    ** proceed by entering \relax
    * [your code goes here]
    * \bye is what you enter at the end what you get is a file named 'texput.dvi' that can be viewed at with a pdfviewer

Sorry for the sidestep, have a Summary:

  • iniTeX . Thing were the \dump primitive is enabled. Meant to create format files. Only knows about TeX primitives.

  • virTeX . Thing were format files can be loaded with ease. Before loading any it only knows about TeX primitives.

  • plainTeX . Sort of but not equivalent to 'virTeX with a file called 'plain.tex' already loaded '. Things like this are like everywhere, they're called LaTeX, ConTeXt AMSTeX, ... referred to as 'formats', as different with 'format-files ' they can only be made with an external (wrt TeX) programm.

  • Note that there are other primitive commands, besides \dump, that are available only in INITEX (and not in a “virgin” TeX), for example \patterns. – GuM Oct 11 '18 at 9:59
-2

The original typesetting system by Donald Knuth is TeX. Leslie Lamport made it easier to use by adding a bunch of macros on top, the result is called LaTeX. Both are TeX at the core, and make absolutely clear you are talking about the original, unadorned, TeX it is sometimes called "plain TeX".

  • 1
    Thanks; I think this is, de facto, one usage of the expression "plain TeX". There are some people that distinguish "plain TeX" from "TeX", though. – Lover of Structure Feb 10 '13 at 4:09
  • Sorry but this is some sense the contrary of what is asked. Instead of explaining "What is plain TeX, and what is the difference to TeX proper?", you're adding to the confusion... – Stephan Lehmke Feb 10 '13 at 9:04
  • 10
    Sorry but this is answer is just wrong. – David Carlisle Feb 10 '13 at 10:54
  • 5
    @vonbrand the other answer explains it to some extent. plain tex is a format just like latex (defined by loading plain.tex into initex just as latex is defined by loading latex.ltx into initex) latex is not built on top of plain tex (although some plain tex macros are copied into the latex sources) – David Carlisle Feb 10 '13 at 12:10
  • 3
    @DavidCarlisle I see, so I think what his answer does get across is that "plain TeX" is often contrasted with LaTeX. From everything written here I understand that technically "plain TeX" is really TeX with the format defined by plain.tex. But for someone not familiar with the matter, the meaning of "plain TeX" might simply be "TeX, not LaTeX", even though this is technically incorrect because the meaning of "plain TeX" is more specific than that. I don't mean to propagate incorrect usage, but I think this is worth pointing out. – Lover of Structure Feb 10 '13 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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