# How exactly are TeX and LaTeX related? [duplicate]

I know that plain TeX is the low-level typographical language that describes nearly every aspect of presentation, taking care of things like paragraph breaks, new pages, and the like.

I know (well, I've inferred) that LaTeX is in fact written in TeX, partly to demonstrate its power and partly for sheer convenience; LaTeX allows the author to construct documents logically rather than 'typographically' as using plain TeX, no-frills, would have you do.

What I don't know is how LaTeX really does it. Does LaTeX compile the document into a PDF, or does it compile the document into plain TeX for tex to actually process? What features does LaTeX actually add on to plain TeX?

-

## marked as duplicate by David Carlisle, lockstep, Sean Allred, Jubobs, ienisseiApr 30 '13 at 12:15

–  Fredrik Pihl Apr 30 '13 at 11:14
@FredrikPihl Thanks for the link; I do know the conceptual differences as well as they can be known, but what I'm asking for is something slightly more tangible. (Although I will add that I don't feel the linked question was answered, IMHO.) While the linked asks 'what separates them,' I ask 'what joins them.' –  Sean Allred Apr 30 '13 at 11:20
It's hard to know what to add that isn't said in the linked question. LaTeX doesn't add to plain. LaTeX and plain tex are each formats written in tex running on a tex engine (tex or pdftex or xetex or luatex or whatever). The source of latex is conceptually just a load of tex definitions no different than the \def or \newcommand that you may put in your document. –  David Carlisle Apr 30 '13 at 11:24
@DavidCarlisle Do you think it'd be better if I edited to ask what LaTeX compiles to? Because an answer to that would likely imply answers to the larger question. (And I would have thought LaTeX would be a bit more complicated, eh?) Would I be better off pulling from the SVN repository and taking a look into the beast itself? –  Sean Allred Apr 30 '13 at 11:27
@SeanAllred \begin is a macro written in TeX just like the rest of latex \def\begin#1{% \@ifundefined{#1}% {\def\reserved@a{\@latex@error{Environment #1 undefined}\@eha}}% {\def\reserved@a{\def\@currenvir{#1}% \edef\@currenvline{\on@line}% \csname #1\endcsname}}% \@ignorefalse \begingroup\@endpefalse\reserved@a} –  David Carlisle Apr 30 '13 at 12:35

TeX has the option of a set of formatting macros called a format. Plain TeX is one of these formats, LaTeX is another, ConTeXt is a third. So in that sense LaTeX is just a layer of helper code over TeX, like a library in a programming language. As far as I understand it (and many here do better than I), prior to pdftex the latex executable was a version of tex pre-compiled with the LaTeX macros “baked in.” As Herbert notes, the pdftex program has many formats baked in and chooses one according the name under which it was called.

-

LaTeX is a link to pdftex:

voss@shania:~> ls -l /usr/local/texlive/2012/bin/x86_64-linux/latex
lrwxrwxrwx 1 voss 1000 6 12. Apr 22:44 /usr/local/texlive/2012/bin/x86_64-linux/latex -> pdftex


Inside pdftex it knows that it was called as latex or pdflatex. The reason why it loads the format LaTeX, which is more or less loading under pdftex the file latex.ltx (the LaTeX kernel), which can be found with kpsewhich latex.ltx. Which program links to another one is listed at Which TeX programs produce dvi output?

-

Leslie Lamport, in his seminal work, LaTeX, A Document Preparation System, User Guide and Reference Manual, Addison-Wesley, 1985, pp.6, describe exactly how LaTeX and TeX are related:

LaTeX is your typographic designer, and TeX is its typesetter.

-
I know exactly the conceptual relationship between LaTeX and TeX; what I was looking for was a more technical explanation. It appears however that I will just have to explore the source for myself ;) –  Sean Allred Apr 30 '13 at 11:41
I think this document may be useful: Michael Downes, TeX and LaTeX2e, available at www.ams.org/notices/200211/comm-downes.pdf –  Papiro Apr 30 '13 at 11:50