What is the difference between TeX and LaTeX?

I know LaTeX and I've heard that LaTeX is a set of macros in TeX. But what does it exactly mean?

-
You should really read tug.org/levels.html –  Martin Schröder Jan 10 '12 at 18:36

TeX is both a program (which does the typesetting, ) and format (a set of macros that the engine uses, ). Looked at in either way, TeX gives you the basics only. If you read the source for The TeXBook, you'll see that Knuth wrote more macros to be able to typeset the book, and made a format for that.

LaTeX is a generalised set of macros to let you do many things. Most people don't want to have to program TeX, especially to set up things like sections, title pages, bibliographies and so on. LaTeX provides all of that: these are the 'macros' that it is made up of.

-
To clarify, the set of macros is called "plain TeX" or "plain", and it's a bit of a misnomer, since one would expect that to refer to nothing but the primitives. –  SamB Dec 1 '10 at 5:23

In short TeX is all about formatting, for document/template designers, while LaTeX is all about content, for document writers.

TeX is a typesetting system. It provides many commands which allow you to specify the format of your document with great detail (e.g. font styles, spacing, kerning, ligatures, etc.), and has specialized algorithms to compute the optimal flow of text in your document (e.g. where to cut lines, pages, etc.). TeX is all about giving you powerful algorithms and commands to specify even the tiniest detail to make your documents look pretty.

LaTeX is a set of macros built on top of TeX. The idea behind LaTeX is to shift the focus from the format to the content of your document. In LaTeX commands are all about giving a structure to the content of your document (e.g. sections, emphasis, tables, indices, etc.). In LaTeX you just say \section{...} instead of: selecting a larger font, a different font style, and inserting appropriate spaces before and after the section heading. As LaTeX is built on top of TeX you also get, of course, a beautiful document as your output; but, more importantly, your source input can also be well structured, easier to read (and write!) for humans.

-
"LaTeX is all about content" is correct, but that's only with LaTeX2e, because in LaTeX 2.09 the distinction between formatting and content was not clear cut. In fact, it was only when LaTeX2e was introduced that I stopped using TeX in favour of LaTeX. –  José Figueroa-O'Farrill Aug 4 '10 at 23:50
@JoséFigueroa-O'Farrill surely latex 2.09 (declared obsolete in 1994) can be regarded as no longer germane to current discussions? (note, the faq, first published in 1995, iirc, still sometimes talks as if latex 2e is a shiny new object ... something more to remember when proof reading (a task like the old "painting the forth bridge") –  wasteofspace Nov 9 '12 at 11:07
Good answer, but there is a bit of ambiguity in the nomenclature. The TeX term for "a set of macros built on top of TeX" is format. Plain TeX is a format, LaTeX is a format, ConTeXt is a format. So maybe it would be better to say TeX is all about formatting. –  Matthew Leingang Apr 30 '13 at 12:01
Is every TeX document a valid LaTeX document? Can we say that LaTeX is just the sample as TeX but with a lot of extra macros predefined? –  Aaron McDaid Aug 31 at 18:09

Don Knuth provide both the TeX typesetting program and the plain TeX macros (the file plain.tex).

TeX the program does the typesetting. The preloaded macros (and the input documents, of course) control what is typeset.

Typically, the macros and input document place items on a horizontal list and then, when the \par command (for example, a blank line) is issued TeX the program breaks the paragraphs into lines.

If you run TeX with \tracingall you can see what are macros and what are TeX commands. I suggest you try this with

 \$ tex '\relax \tracingall \input story \end'


rather than a LaTeX document. LaTeX does a lot of macro processing, particularly for font selection.

-

TeX, LaTeX, ConTeXT - different languages / syntax for typesetting.

For each of these there are many engines available that can process the above syntax and generate dvi, ps, pdf, html, svg.... and what not.

To confuse even more there are engines called tex and latex, which can be used to process tex and latex syntaxes respectivly to produce dvi outputs.

@José Figueroa-O'Farrill:

Treating the system as blackbox: ConTeXt, LaTeX and TeX have significantly different syntax and different compilers hence they are different. And most users do not need to know that one is using the other behind the scene, that's an implementation detail. The beginner user needs to know that (a) they are different (b) they all produce awesome quality documents (c) each package has its own "native" way to do stuff (d) you can seek for all of them here.

-
I don't understand the downvotes. This is somewhat terse, but there's nothing particularly wrong with this. What happened to "please consider adding a comment if you think this post can be improved"? –  ShreevatsaR Jul 28 '10 at 18:15
I'm voting this up. It's a fine answer. –  Chris Phan Aug 4 '10 at 21:55
I didn't vote this down, but I don't agree that TeX and LaTeX are different languages. LaTeX (as of today) is still a set of TeX macros. –  José Figueroa-O'Farrill Aug 4 '10 at 22:41
And: there is no engine called latex. It is just the format. (I didn't downvote either, but the answer is misleading). –  topskip Aug 5 '10 at 5:37