LaTeX Introduction
LaTeX is a typesetting system based on TeX, widely used to produce high-quality scientific and mathematical documents, developed by American computer scientist Leslie Lamport in the 1980s.
TeX is a low-level typesetting engine developed by Donald Knuth, mainly used for handling complex mathematical formulas and high-quality typesetting.
LaTeX provides a higher level of abstraction on top of TeX, allowing users to focus more on content without worrying too much about typesetting details.
Unlike common word processors (such as Microsoft Word), LaTeX uses plain text files to describe the structure and content of a document and generates the final PDF through compilation. LaTeX is especially suitable for handling complex math formulas, references, and cross-references.
LaTeX was originally designed to facilitate the typesetting of academic papers and technical documents, especially in fields such as mathematics, physics, and computer science. Over time, LaTeX gradually became one of the standard tools in academia and publishing.
LaTeX Features
- High-quality typesetting: LaTeX is known for its professional typesetting results, especially its excellent handling of math formulas. It automatically adjusts document formatting to produce high-quality results that meet publishing standards.
- Markup-language based: LaTeX uses a plain-text markup format; users define document structure and formatting by entering specific commands and tags. For example, \section{} defines a section and \textbf{} makes text bold.
- Cross-platform support: LaTeX is cross-platform, supporting operating systems such as Windows, macOS, and Linux. Generated documents are usually in PDF format and display consistently across platforms.
- Suitable for academic writing: LaTeX is ideal for writing academic papers, books, technical documents, and reports, especially documents with many math formulas, references, and complex typesetting needs. It offers excellent support for bibliography management, formula input, and typesetting.
- Automated document management: LaTeX provides powerful automation for long documents, books, or theses, such as automatic numbering, automatic table of contents generation, cross-references, and automatic formula layout. It handles citations and reference lists automatically, ideal for documents requiring precise formatting.
- Open source and free: LaTeX is open source; anyone can download and use it for free. The LaTeX community is also very active, providing many templates, packages, and tips to help users improve typesetting efficiency.
How Does LaTeX Work?
- Unlike traditional WYSIWYG editors, LaTeX does not show the final typeset result directly; instead, you edit a plain text file and enter the document's content, structure, and formatting instructions. This file usually has the .tex extension.
- Writing LaTeX source code: first, you use a text editor (such as TeXworks or TeXstudio) to write the LaTeX source file. You specify the document's structure, title, paragraphs, formulas, and tables, and use LaTeX commands to specify how to format them.
- Compilation: then, you use a LaTeX compiler (such as pdflatex) to compile the .tex file into PDF or another output format. During compilation, LaTeX automatically generates the table of contents, tables, formula numbers, references, etc.
- Generating the final document: the compiled output is the final document; you can view the PDF result, which is typeset to high quality according to your formatting requirements.
Why Use LaTeX?
- Academic writing: if you are a researcher, scholar, or student, LaTeX is ideal for writing academic papers, reports, and books, especially documents that need complex math formulas and references.
- High-quality typesetting: LaTeX automatically handles typesetting details and can produce document formats that meet international publishing standards. Whether fonts, line spacing, margins, or section title formats, LaTeX controls them precisely.
- Complex document structures: LaTeX is suitable for large documents (such as books, theses, technical manuals); it can automatically generate tables of contents, indexes, and references, and supports cross-references and automatic numbering.
- Mathematical and scientific literature: LaTeX is the preferred tool in mathematics, physics, engineering, etc., because it easily enters and typesets complex math formulas.
LaTeX vs. Word
| Feature | LaTeX | Microsoft Word |
|---|---|---|
| Typesetting Quality | Professional-grade typesetting, especially good at complex formulas and long documents. | Suitable for simple documents; complex typesetting needs manual adjustment. |
| Learning curve | Requires learning basic syntax; harder to pick up at first. | WYSIWYG, easy to get started. |
| Degree of Automation | Automatically handles numbering, cross-references, table-of-contents generation, etc. | Requires manual adjustment of numbering and formatting. |
| Math Formula Support | Powerful math formula typesetting, supports complex symbols and structures. | Limited formula editing; complex formulas are hard to handle. |
| Cross-platform support | Fully cross-platform; documents behave consistently across systems. | Decent cross-platform support, but formatting may vary by version. |
| Document Structure | Content and format are separated, easy to maintain and collaborate. | Content and format are mixed, making long documents harder to maintain. |
| Extensibility | Extends functionality via packages; supports custom commands and environments. | Functionality extension relies on plugins, with lower flexibility. |
LaTeX's workflow can be summarized in three steps: write source code, run compilation, get PDF.
The .tex file we write is an ordinary plain-text file that can be opened with any editor; the compiler turns it into the final PDF.
LaTeX's Basic Workflow
The basic process of writing a document with LaTeX is as follows:
- Write source code: use a plain-text editor to write the .tex file, whose content includes document structure, text, and commands.
- Compile the document: use a LaTeX compiler (such as pdflatex, xelatex) to convert the .tex file to PDF or another format.
- View the result: the generated PDF can be viewed directly; the content is typeset automatically from the source code.
For example, a simple LaTeX document is as follows:
Example
\
documentclass
{
article
}
% document class
\
title
{
My First LaTeX Document
}
% title
\
author
{
Author
}
% author
\
date
{
\today
}
% date
\begin
{
document
}
\
maketitle
% generate title
\
section
{
Introduction
}
% section
This is my first LaTeX document!
\
% line break
This is a simple paragraph.
\
section
{
Math Formulas
}
This is an inline formula:
$E = mc^2$
.
\
% inline formula
This is a display formula:
[
\int_a^b f(x) \, dx
\
]
\end
{
document
}
LaTeX's Core Idea
LaTeX's core idea is the separation of content and format:
- Users only need to focus on the document's content and structure; LaTeX automatically handles typesetting details.
- Document structure and style are defined through commands and environments (such as \section, \begin{itemize}).
- Format adjustments are made by modifying the document class or loading packages, without directly changing the content.
The Relationship Between TeX, LaTeX, Packages, and Distributions
This is the most easily confused set of concepts for beginners; clarifying them means you will never get lost choosing tools or setting up the environment later.
The entire TeX ecosystem can be divided into four layers, from bottom to top: engine, format, package, and editor.
The engine is the program that actually does the typesetting; common ones are TeX, pdfTeX, XeTeX, and LuaTeX. Among them, XeTeX and LuaTeX natively support Unicode and system fonts, which is why they are recommended for compiling Chinese documents.
The format is a set of command rules built on top of the engine; LaTeX is currently the most popular format.
Packages are plugins that further extend functionality on top of the format, such as Chinese support (ctex), math enhancement (amsmath), and page setup (geometry). CTAN hosts over five thousand packages.
Finally, a collection that bundles the engine, format, and a vast number of packages for one-time installation is called a distribution, such as TeX Live and MiKTeX.
Remember Five Terms in One Sentence
Engine: the program that actually typesets source code into PDF, such as XeTeX.
LaTeX format: a set of handy command rules defined on top of the engine.
Package: a ready-made function extension written by others, such as the Chinese support package ctex.
Distribution: a complete installer that bundles the engine, format, and packages together.
Editor: the software you write code in; it does not participate in typesetting itself.
An editor is not a compiler. Overleaf, TeXstudio, and VS Code only write code and trigger compilation; the actual typesetting is done by the engine in the distribution. So in a local environment, installing only the editor without a distribution cannot produce a PDF (Overleaf is the exception, as its cloud includes a complete distribution).
LaTeX's Advantages and Use Cases
LaTeX is not a universal tool, but in the following scenarios its efficiency and quality advantages are very clear.
| Scenario | Why It Fits |
|---|---|
| Academic Papers and Theses | Most journals and universities provide official LaTeX templates; formulas, figures, tables, and reference numbering are all automatic |
| Science and engineering lecture notes in math, physics, etc. | Fast formula input; typesetting quality of complex formulas (matrices, equation systems, multi-line derivations) far exceeds rich-text editors |
| Books and Long Reports | Automatic chapter management and globally consistent styles; documents of hundreds of pages still stay format-consistent |
| Resumes | Templates like moderncv produce polished layouts; content and style are separated, so changing content does not break the layout |
| Presentations | Beamer can produce academic slides with perfect formula typesetting, which is hard for PPT to achieve |
Conversely, do not force LaTeX in these cases: posters needing heavy graphic design, office documents requiring multi-person real-time annotation, and short documents with few formulas that must be finished the same day; Word or specialized tools are more convenient.
LaTeX's learning curve is steep at first then flattens: in the first few days you may feel "even changing the font size requires looking up a command," but by finishing the basics of this series you will appreciate the long-term benefits of automated typesetting.
Common Distribution Comparison
A distribution solves only one problem: it saves you from installing the engine and packages one by one.
| Distribution | Supported platforms | Size | Feature | Suitable for |
|---|---|---|---|---|
| TeX Live | Windows / macOS / Linux | Full about 8 GB, Basic scheme about 300 MB | Officially maintained by TUG, one release per year, consistent behavior across the three platforms | The first choice for most users |
| MacTeX | macOS | Full about 5 GB, Basic about 100 MB | The macOS version of TeX Live, bundled with small GUI tools | Mac users |
| MiKTeX | Mainly Windows | Basic about 300 MB | Packages downloaded automatically on demand; small initial install | Windows users, tight disk space |
| TinyTeX | Windows / macOS / Linux | About 100-200 MB | Minimal distribution; install packages on demand via command line | Users familiar with the command line, servers, and CI environments |
When downloading TeX Live or packages in China, it is recommended to switch the software source to a domestic mirror such as Tsinghua TUNA; the speed can be an order of magnitude faster.
Choosing an Editor
The editor determines your "writing" experience; it can be changed at any time and is independent of the distribution.
| Editor | Type | Advantages | Limitation | Who It's For |
|---|---|---|---|---|
| Overleaf | Online | No installation, built-in compilation environment, rich template library, supports collaboration | Unavailable offline; the free version has limits on compilation time and number of projects | Beginners (recommended by this tutorial) |
| TeXstudio | Local Desktop | Free and open source, strong command completion and error hints | Interface is rather traditional | Users who prefer local writing |
| VS Code + LaTeX Workshop | Local Plugin | Modern interface, Git-friendly, integrated compile preview | Requires some configuration | Developers already using VS Code |
| TeXworks | Local Desktop | Bundled with TeX Live, ready to use out of the box | Fewer features | Writing short documents temporarily |
It is recommended to start with Overleaf https://www.overleaf.com/, zero configuration to directly follow the tutorial and type code; when you need offline writing or version management, then set up a local environment.
Sneak Peek: A Complete LaTeX Source File
Before formally setting up the environment, take a look at what a real LaTeX document looks like.
The source below is complete and compilable, including Chinese text, a title, and two math formulas.
Example
% document class: ctexart is equivalent to article plus Chinese support
\
documentclass
{
ctexart}
\title{我的第一份 \LaTeX{} 文档
}
% document title
\
author
{
RUNOOB
}
% author
\
date
{
August 2026
}
% date; writing \today auto-fills the current day
\begin
{
document
}
% body starts here
\
maketitle
% generate title block
LaTeX is especially good at math formula typesetting. The inline form of the mass-energy equation is
$E = mc^2$
,
To display it centered on its own line (display formula), write:
[
E = mc^2 \
]
where
$E$
is energy,
$m$
is mass,
$c$
is the speed of light in a vacuum.
\end
{
document
}
% body ends here
After compiling this source, the resulting PDF page is as follows:

Not understanding these commands now is completely normal; each later part of this series will break them down one by one.
Here you only need to remember two structures: from \documentclass to \begin{document} is called the preamble, used for global settings; between \begin{document} and \end{document} is called the body, where you write content.