Fix: Undefined control sequence

pdfLaTeX stopped at a command it has never heard of. The error always names the line — the fix is on that line or in the preamble above it.

What the log looks like

! Undefined control sequence.
l.5 This one calls a command that was never defined: \makethingsbetter

The line after l.5 echoes your source with the offending command at the break point.

The three usual causes

  1. A typo. \secion instead of \section. Fix the spelling.
  2. A missing package. Commands like \includegraphics or \toprule only exist after \usepackage{graphicx} / \usepackage{booktabs}. Add the \usepackage line to the preamble.
  3. A custom command used before it is defined. \newcommand lines must come before the first use — usually in the preamble, after \documentclass.

Reproduce and fix it now

The example below calls a command that does not exist. Compile it, see the error point at line 5, then delete or rename the command and compile again.

Open the repro in the editor →

Still failing?

  • Check for a package the bundled engine does not carry — the compile log names the missing file (see file not found).
  • Copy-pasted source sometimes carries invisible Unicode; retyping the offending line is faster than hunting it.