Is there any situation where it is preferable to use TeX (or perhaps plain TeX) rather than LaTeX to write a document?

  • 8
    plainTeX is faster. And often you need less characters of input to achieve more or less the same output for simple documents, hence I often use it when I'm writing answers for code golfing in TeX. But perhaps you should wait for the people's answers who use plainTeX for their actual documents...
    – Skillmon
    Nov 30, 2019 at 17:24
  • 1
    I often mix them. It may make the macros more performant, and sometimes easier to write (in the low-level area, most is documented in terms of plain TeX). Also, things like en.wikibooks.org/wiki/LaTeX/Plain_TeX#Arithmetic (yeah, there are probably newer methods available, they just take more effort to learn… and then there’s expl3 which is completely illegible…)
    – mirabilos
    Dec 3, 2019 at 0:39
  • 1
    LaTex uses Tex, so the latter has to be better. Dec 3, 2019 at 20:45
  • All the time, of course. Dec 3, 2019 at 23:54

4 Answers 4

  • TeX is useful when you want to fully understand what's going on, or want to have full control. In principle this is possible with LaTeX too, but there's a lot more to understand. (That is, LaTeX is easy but not simple, while plain TeX is simple but not easy. Related talk on software design.)

  • TeX is a tool for typesetting; LaTeX is a document preparation system. IMO TeX is useful when you want to play the role of the printer/typesetter; LaTeX is useful when you want to play the role of the author.

To elaborate on the second point: Once upon a time, books were produced in the following way:

  • The author would write their manuscript (the contents of the book) either by hand (with pen or pencil on paper), or with a typewriter, or something like that, and then (after editing and proofreading etc), send it to a printer (a person).

  • The printer (a person, not a machine!) would have the job of taking this content, and turning them into pages: picking up pieces of metal type (for each letter), spacing them into equal-length lines, adding spaces here and there, and so on. (Literally, setting type, so typesetter.)

TeX was originally written to help with the latter job (Knuth already had most of the content; he was only producing the second edition of his book (TAOCP Vol 2)); later Leslie Lamport realized that this was all too low-level for authors, and came up with LaTeX. So it is hard to recommend writing a book from scratch in plain TeX; you'll probably end up with your own complex macros just like LaTeX. But if you already have the content in another format and just want to solve a problem very specific to pages of a certain known size, it is possible that it may be easier to do it using plain TeX (using as few macros as possible) than with LaTeX.

To give a somewhat trivial example of the first point: consider the font-changing commands. Plain TeX produces a way to say "start using the following font", something specific like "Computer Modern italic at 9pt". Of course you probably want to switch back to roman type at the end of it, so you need to be careful to enclose this command in a group. But not just that: you're probably using italics for emphasis, and if within something that is emphasized you want to emphasize further, then the convention is to switch back to roman type. Also, if you want to emphasize something within bold, you should switch not to regular italics, but to bold italics. Similarly if your font is larger then you should switch to the larger italic font. All this sort of thing LaTeX's default \emph does automatically. This is usually what you want, if you're writing a document. But if for some reason you want to explicitly control which font gets used where, then you may not know how to do it with LaTeX, and when you figure out you'll be using something so far from typical LaTeX that it's closer to plain TeX.

Here's another example, thanks to Bruno Le Floch's unravel package. Compare what happens internally when you run the LaTeX \newcommand, versus the plain TeX \def:

\unravel{\newcommand*{\foo}[1]{bar(#1)}}   % The LaTeX way
\unravel{\def\foo#1{bar(#1)}}              % The plain-TeX way

As printed by unravel, the former takes 126 steps, while the latter takes 2 steps. This example illustrates quite a few other points of difference between LaTeX and plain TeX:

  • The plain TeX way is still technically available in LaTeX, just discouraged.
  • Plain TeX markup can often be shorter (by doing less: see next point).
  • The LaTeX way is probably what most authors want, as it is born of experience and provides additional protections (in this case, against the all-too-common possibility of accidentally redefining an existing command).
  • Still, overall, very few people using LaTeX would be aware of everything that \newcommand is doing under the scenes, so it's less conducive to understanding exactly what is going on.

As yet another example (last one I promise), compare a standard LaTeX way to get a bulleted list:


Some text.
\item first
\item second
More text.


with the way Knuth does it in texbook.tex (corresponding to page 10):

% TeXbook uses "\input manmac"; for this example just need the following from it.
\def\bull{\vrule height .9ex width .8ex depth -.1ex } % square bullet
% These 3 are already in plain.tex, reproduced here as they may be less familiar.

Some text.
\item\bull first
\item\bull second
More text.


If you surround the "Some text... More text" with \tracingmacros=1 and \tracingmacros=0, you get about 25 times more lines in the LaTeX case. More importantly, the LaTeX way is probably closer to the author's mind, and the TeX way shows clearly all the typesetting that's going on.

  • 17
    +1 This is a great answer. And the unravel package is amazing.
    – Alan Munn
    Dec 1, 2019 at 16:11
  • 1
    As far as I know, Knuths parents owned a print-shop. So Knuth had a lot of insight regarding typesetting (in the good old fashion way). In my opinion, this influenced the way he designed TeX, which exactly led to your conclusion: TeX is the typesetter. I tell my students, that the great advantage of LaTeX is its \documentclass command, which puts all the typographic- and layout-wisdom into the documents of an otherwise uneducated person.
    – Jan
    Dec 4, 2019 at 7:08
  • @Jan Yes Knuth says he must have inherited a love for printing from childhood and his father's printing shop (a simple mimeograph machine or something like that), though of course the insight into typesetting he got later when he got interested in the problem, via serious study of many books, and working with the world's top font designers etc. As for LaTeX, I used to think the same too, but it's actually not so IMO: what LaTeX does out-of-the-box is only a very small part of what good typesetting involves/requires. Why, many LaTeX users don't even bother about overfull/underfull box warnings! Dec 4, 2019 at 9:24
  • @ShreevatsaR I agree to overfull warnings. But bear in mind, that LaTeX was invented, when AI (Artificial Intelligence) was far from reach (and to my humble opinion is still today :-)). Nevertheless, Knuth and Lamport were so clever, to bother us with those warnings, so that you could -- depending on your NI (Natural Intelligence) -- act on them accordingly.
    – Jan
    Dec 4, 2019 at 10:26

The question has no answer, actually it meets the standard "opinion based" close reason. but I'll attempt an answer anyway.

TeX is a macro expansion language, and

LaTeX is defined as a set of macros, so everything that you write in LaTeX expands eventually to some sequence of TeX primitives.

Conversely, TeX allows you to define macros, so starting from just the primitives (initex) or from plain TeX, you could define macros equivalent to LaTeX.

So at some level the capabilities are identical. For vast majority of people for the majority of the time, it is best to use LaTeX, as whatever the technical pros and cons, LateX, basically forms a language of communication that has meaning separate from its implementation in the TeX typesetter, and writing in a common language with a shared understanding has its uses. If you write your own TeX macros, even if they typeset equivalent documents, those documents will be harder for other humans and other systems to understand.

Aside from the shared language aspects, the LaTeX macros are not always the implementation you would choose now (they were designed for far smaller machines) but they have been used by millions of users for decades and the chances are that most of the more serious bugs are either fixed or have known workarounds. If you "roll your own" document macros while it is in theory possible that they could be as robust, it's somewhat unlikely, millions of man hours of testing time are hard to beat.

Since I've been part of the team maintaining LaTeX for over 25 years this perhaps is not the most objective neutral comparison that you could get, but still...

Since it's December it's probably a good time of year to point out that I do use plain tex sometimes, this plain tex that I wrote a while back has had some use over the years for example.

Fjfi71PAVVFjbigskipRPWGAUU71727374 75,76Fjpar71727375Djifx
RrhC?yLRurtKFeLPFovPgaTLtReRomL;PABB71 72,73:Fjif.73.jelse
B73:jfiXF71PU71 72,73:PWs;AMM71F71diPAJJFRdriPAQQFRsreLPAI
I71Fo71dPA!!FRgiePBt'el@ lTLqdrYmu.Q.,Ke;vz vzLqpip.Q.,tz;
;Lql.IrsZ.eap,qn.i. i.eLlMaesLdRcna,;!;h htLqm.MRasZ.ilk,%
s$;z zLqs'.ansZ.Ymi,/sx ;LYegseZRyal,@i;@ TLRlogdLrDsW,@;G
LcYlaDLbJsW,SWXJW ree @rzchLhzsW,;WERcesInW qt.'oL.Rtrul;e
doTsW,Wk;Rri@stW aHAHHFndZPpqar.tridgeLinZpe.LtYer.W,:jbye
  • 13
    Show off!!! (+1) Dec 1, 2019 at 1:27
  • 3
    Did that plain tex get developed for codegolfing initially?
    – masterX244
    Dec 2, 2019 at 11:13
  • 5
    @masterX244 well actually it was posted to a comp.text.tex thread on how to count words in tex documents (you can find several posts on this site giving some history and deconstruction of the macros) (search for xii) Dec 2, 2019 at 11:18
  • Memorizing this cryptic code and retyping it is hard. It must be copied and pasted from your archives. Dec 4, 2019 at 9:49
  • 1
    @MoneyOrientedProgrammer you almost certainly have a copy installed already (it's in miktex and texlive) try pdftex xii and it should run. Dec 4, 2019 at 11:21

I'm a long time LaTeX user (I found it difficult to understand the TeXbook) but I'm approaching this from a computer programming viewpoint. My first introduction to programming was a course at the local technical college about machine code (a bunch of 0's and 1's) --- terrible, especially when I learned that the college had no computer and therefore no way, apart from manually, checking the code we submitted; it was easy after that, just hand in sequences of random 0's and 1's! But basically computers understood machine code.

Then there was Assembly code which at least was somewhat readable if not easily uderstandable. And there were programs that converted Assembly into machine code.

Then came programming languages like FORTRAN or C or Java which provided high level ways of talking about things --- much more attuned to human understanding (provided you were a computer programmer). These came with compilers which would essentially convert the langauge to Assembly and then that would be converted to machine code and then the computer would do wonderful things.

My feeling is, that although TeX can do what you want, it is akin to Assembly code while LaTeX is akin to FORTRAN or Java where it is much easier to describe what you want. Just like the programming languages LaTeX gets "converted" to TeX.

Do you want to operate at a high level of expression or a low level? Lower might be more processor efficient but higher might be more generally understandable.

A TeX document will probably compile quicker than a Latex document, but we are talking here about (fractions of) seconds. Compare this with the time you have to spend crafing a TeX document to match your needs versus LaTeX which provides many of the solutions you might need to code with TeX.

  • 3
    Though this analogy captures something about TeX/LaTeX (expressing the semantics of your document versus low-level typesetting commands), it's also slightly misleading IMO. LaTeX doesn't really provide a new programming language itself (unless you count expl3); one still needs to "program" in TeX macros. Another analogy may be building your own website versus using (say) WordPress: works well, has many convenient packages, but to customize something you need to either find a setting or a plugin (or drop down to low-level programming with the added burden of understanding someone else's code). Dec 2, 2019 at 21:34
  • 1
    BTW I too found the TeXbook difficult to understand, but A Beginner's Book of TeX by Seroul and Levy is a very nice introduction to an excellent subset of plain TeX... can make one fall in love with the system :-) Dec 3, 2019 at 5:52

A few years ago I threw some effort into learning plain TeX. I did this because:

  • I find LaTeX output ugly
  • I was learning ConTeXt, and its documentation often suggests you drop down to plain TeX when you want to do something complex

Specifically with LaTeX, I often find that it has made some decision, ostensibly to free you from having to think about something, and you dislike the decision it made. Your options will be to either read the LaTeX code and find out what is happening and how (which is not easy), find a package that fixes this little thing (often possible, but sometimes feels gross), or suffer.

With plain TeX, you are the one responsible for whatever behavior you see, so if you don't like it, it's your fault, and you can understand what you did wrong. Or at least ask here on tex.SE. :)

By the way, if you want to learn plain TeX, I would recommend you start from XeTeX or LuaTeX because the font situation is much easier from those engines.

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