Introduction
LaTeX (pronounced “LAH-tekh” or “LAY-tekh”) is a typesetting system widely used in academia, especially in mathematics, physics, and computer science. Unlike word processors such as Microsoft Word, LaTeX separates content from formatting — you write plain text with markup commands, and a compiler produces a polished PDF.
LaTeX is built on top of TeX, a typesetting engine created by Donald Knuth in the late 1970s. Leslie Lamport later developed LaTeX as a higher-level set of macros to make TeX easier to use. Today, LaTeX is the dominant system for producing mathematical documents, journal papers, theses, and books.
Why LaTeX?
- Superior math typesetting: LaTeX handles complex equations, theorems, and proofs beautifully.
- Consistent formatting: Templates and document classes enforce uniform styling.
- Cross-referencing: Automatic numbering of sections, equations, figures, theorems, and citations.
- Plain text source: Works well with version control (e.g., Git) and collaboration.
- Free and open source: No license fees.
Frontend (Editors) vs Backend (Compilers)
A LaTeX workflow has two parts:
Frontend — Editors
The editor is where you write your .tex source files. Popular options include:
| Editor | Type | Notes |
|---|---|---|
| VS-Code + LaTeX Workshop | General-purpose editor | Free, powerful, highly customizable. Recommended. |
| Overleaf | Online editor | No installation needed. Great for collaboration. Free tier available. |
| TeXstudio | Dedicated LaTeX IDE | Free, cross-platform, feature-rich. |
| TeXmaker | Dedicated LaTeX IDE | Free, clean interface. |
You could find a complete list of LaTeX editors at https://en.wikipedia.org/wiki/Comparison_of_TeX_editors.
Backend — Compilers
The compiler (also called a TeX engine) processes your .tex file and produces a PDF. Common engines:
| Engine | Description |
|---|---|
pdflatex | The classic default. Compiles .tex → PDF directly. Does not support Unicode natively. |
xelatex | Supports Unicode and system fonts out of the box. Good for multilingual documents. |
lualatex | Modern engine with Lua scripting support. Also supports Unicode and system fonts. |
Most LaTeX editors let you choose which engine to use. For typical math documents, pdflatex works fine. If you need special fonts or non-Latin scripts, use xelatex or lualatex.
Installation
TeX Live (Backend Compiler)
TeX Live is the recommended LaTeX distribution. It includes all the major compilers (pdflatex, xelatex, lualatex), a large collection of packages, and supporting tools.
macOS
# Option 1: Install MacTeX (TeX Live for macOS, includes GUI tools)
# Download from https://tug.org/mactex/
# Option 2: Install via Homebrew (smaller, command-line only)
brew install --cask mactex-no-guiWindows
- Download the installer from https://tug.org/texlive/windows.html
- Run
install-tl-windows.exe - Follow the prompts — the default options are fine
- Installation takes a while (~5 GB full install)
Linux (Ubuntu/Debian)
sudo apt install texlive-fullVerify installation
pdflatex --version
xelatex --versionVS Code (Frontend Editor)
See VS-Code for full installation and configuration instructions, including:
- Installing VS Code
- Setting up the LaTeX Workshop extension
- Compiling and previewing PDF
- Forward/backward SyncTeX
Usage
Basic Document Structure
\documentclass{article}
\usepackage{amsmath, amssymb, amsthm} % math packages
\title{My First Document}
\author{Your Name}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
Hello, this is my first LaTeX document.
\section{Math}
The quadratic formula is
\[
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}.
\]
\end{document}Common Math Commands
% Inline math
The variable $x$ satisfies $x^2 + 1 = 0$.
% Display math
\[
\int_0^\infty e^{-x^2} \, dx = \frac{\sqrt{\pi}}{2}
\]
% Aligned equations
\begin{align}
f(x) &= x^2 + 2x + 1 \\
&= (x+1)^2
\end{align}
% Matrices
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
% Theorem environments (requires amsthm)
\newtheorem{theorem}{Theorem}
\begin{theorem}
Every bounded sequence has a convergent subsequence.
\end{theorem}Useful Packages
| Package | Purpose |
|---|---|
amsmath | Enhanced math environments (align, gather, etc.) |
amssymb | Additional math symbols |
amsthm | Theorem environments |
geometry | Page margin control |
hyperref | Clickable links and cross-references |
graphicx | Include images |
tikz | Programmatic drawings and diagrams |
biblatex | Modern bibliography management |
enumitem | Customizable lists |
Compiling from Command Line
# Using latexmk (automates multiple runs)
latexmk -pdf myfile.texYou could also use GUI-based approach or auto-compile (see VS-Code) for building with VS Code (using the LaTeX Workshop extension's build toolbar or auto-save compilation).
For simpler documents that don't require LaTeX's full typesetting power, consider using Markdown. Markdown uses a much lighter syntax (e.g.,
# Heading,**bold**,- list item) and doesn't need a compiler — most editors render it instantly. It also supports basic math via LaTeX syntax (e.g.,$x^2$) in tools like Obsidian, Jupyter, and GitHub. See the Markdown note for usage details.