The preamble is everything that lies between \documentclass and \begin{document}. This is where you load extensions (packages) with \usepackage. Many commands only exist if their package is loaded.
An unknown command = a missing package
If you use a “special” command without loading its package, LaTeX replies “Undefined control sequence”.
Fix This document uses
\mathbb without loading the package that provides it → error. Add \usepackage{amssymb} to the preamble, then compile. Learn more →Show the solution
\documentclass{article}
\usepackage{amssymb}
\begin{document}
The set of real numbers is written $\mathbb{R}$.
\end{document}Loading several packages
amssymb,amsmath: mathematical symbols and environments.xcolor: colour (\textcolor,\colorbox).graphicx: images (\includegraphics).hyperref: links (\href,\url).
Complete The word “warning” must appear in red via
\textcolor{red}{...}. But the package that provides colours is missing: add it to the preamble, then compile.Show the solution
\documentclass{article}
\usepackage{xcolor}
\begin{document}
\textcolor{red}{warning}: now the xcolor package is loaded.
\end{document} Key takeaway: a special command (maths, colours, images, links…) needs its
\usepackage in the preamble. “Undefined control sequence”? Look for the missing package.