Getting Started

What Is the Difference Between TeX and LaTeX?

TeX is the typesetting engine created by Donald Knuth. LaTeX is a macro package built on it by Leslie Lamport. Here is how they differ and work together.

On this page
  1. Short answer
  2. What TeX is
  3. What LaTeX adds
  4. A small LaTeX example, line by line
  5. Engines and formats: pdfTeX, XeTeX, LuaTeX
  6. Why people say “LaTeX” for the whole system
  7. Which one should you use?

Short answer

TeX is a typesetting system and programming language created by Donald Knuth. It handles the low-level work of placing characters, breaking lines, and laying out pages. LaTeX is a macro package built on top of TeX by Leslie Lamport. It gives you high-level commands for documents, such as sections, lists, tables, cross-references, and bibliographies. In everyday use, people say “LaTeX” for the whole system, and that is the sense this guide uses.

What TeX is

TeX is the engine and the language underneath. Donald Knuth created it in the late 1970s to produce high-quality typeset mathematics and text. It decides where line breaks and page breaks go, how spacing works, and how math is arranged.

Plain TeX is the original set of low-level commands. Writing a document in plain TeX means working with that low-level layer directly, so you control spacing and fonts by hand. Few people write long documents this way today.

What LaTeX adds

LaTeX sits on top of TeX and adds a layer of structure:

  • Document classes, such as article, report, and book, which set up page layout and standard sections.
  • Structural commands, such as \section, \subsection, and \begin{itemize}.
  • Cross-references and automatic numbering for sections, figures, tables, and equations.
  • Bibliographies and citations through .bib files and processing tools.
  • Packages, which add features such as colored text, graphics, and page geometry.

Leslie Lamport wrote LaTeX in the 1980s to make TeX easier to use for everyday documents, while keeping its typesetting quality.

A small LaTeX example, line by line

\documentclass{article}       % choose the document class (layout rules)
\usepackage{amsmath}          % load an extra package for math

\begin{document}              % the body of the document starts here

\section{Introduction}        % a numbered section heading
The energy is $E = mc^{2}$.   % inline math between dollar signs

\end{document}                % the body ends here
  • \documentclass sets the overall layout. LaTeX applies its rules automatically.
  • \usepackage loads a package. Here, amsmath adds extra math features.
  • \begin{document} and \end{document} mark the body. Everything you write goes between them.
  • \section creates a numbered heading without you setting its size or spacing.

In plain TeX, you would have to define the heading and spacing yourself. LaTeX gives you the command and handles the layout.

Engines and formats: pdfTeX, XeTeX, LuaTeX

TeX has several modern engines. Each one is a program that reads your source and writes output, and each one runs LaTeX (or other formats) on top:

  • pdfTeX, run with pdflatex, is the most common engine. It writes PDF directly.
  • XeTeX, run with xelatex, adds better support for system fonts and Unicode text.
  • LuaTeX, run with lualatex, uses the Lua programming language for extra control and also supports system fonts.

Each command runs LaTeX on a different engine. Most documents build with pdflatex, but if you need a specific font or a non-Latin script, xelatex or lualatex may be the better choice. The one that works for your document depends on its needs.

What pdflatex, xelatex, and lualatex run

When you type pdflatex main.tex, the command starts the pdfTeX engine and loads the LaTeX format. The same is true for xelatex and lualatex, with their own engines. That is why all three commands read LaTeX syntax, but they produce output in slightly different ways.

Why people say “LaTeX” for the whole system

When someone says “I use LaTeX,” they usually mean all of the following together:

  • The source language you write in
  • The LaTeX format and its packages
  • The engine that compiles the source
  • The distribution that installs these tools, such as TeX Live or MiKTeX
  • The editor where you write

The names TeX and LaTeX are often used loosely for this whole system. Knowing the distinction helps when you read documentation or error messages that name a specific engine.

Which one should you use?

For nearly all documents, use LaTeX. It gives you the structure, packages, and document classes that most people need, and it sits on the same typesetting engine as TeX. Plain TeX is mainly of interest to people who study the typesetting system itself or who write their own macro packages.

To set up LaTeX, start with getting started with LaTeX. Then install a distribution on your system, such as install LaTeX on Windows 10 or how to install LaTeX on Ubuntu with TeX Live.

The complete guide to getting started

Getting Started with LaTeX: Document Preparation, Editors and Workflow
Read the guide

Keep exploring

Guides from other topics

All topics →