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:

EditorTypeNotes
VS-Code + LaTeX WorkshopGeneral-purpose editorFree, powerful, highly customizable. Recommended.
OverleafOnline editorNo installation needed. Great for collaboration. Free tier available.
TeXstudioDedicated LaTeX IDEFree, cross-platform, feature-rich.
TeXmakerDedicated LaTeX IDEFree, clean interface.

You could find a complete list of LaTeX editors at https://en.wikipedia.org/wiki/Comparison_of_TeX_editors.

For most users, VS-Code with the LaTeX Workshop extension is recommended. See the VS-Code note for detailed setup instructions.

Backend — Compilers

The compiler (also called a TeX engine) processes your .tex file and produces a PDF. Common engines:

EngineDescription
pdflatexThe classic default. Compiles .tex → PDF directly. Does not support Unicode natively.
xelatexSupports Unicode and system fonts out of the box. Good for multilingual documents.
lualatexModern 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-gui

Windows

  1. Download the installer from https://tug.org/texlive/windows.html
  2. Run install-tl-windows.exe
  3. Follow the prompts — the default options are fine
  4. Installation takes a while (~5 GB full install)

Linux (Ubuntu/Debian)

sudo apt install texlive-full

Verify installation

pdflatex --version
xelatex --version

VS 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

PackagePurpose
amsmathEnhanced math environments (align, gather, etc.)
amssymbAdditional math symbols
amsthmTheorem environments
geometryPage margin control
hyperrefClickable links and cross-references
graphicxInclude images
tikzProgrammatic drawings and diagrams
biblatexModern bibliography management
enumitemCustomizable lists

Compiling from Command Line

# Using latexmk (automates multiple runs)
latexmk -pdf myfile.tex

You 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.