Let
X
Error

LaTeX Error: Undefined control sequence

The fix

The "Undefined control sequence" error means LaTeX hit a command it does not recognize — usually a typo in the command name, or a missing \usepackage for the package that defines it. Fix it by correcting the spelling or adding the required package to your preamble.

Why it happens

LaTeX reports the offending command on the error line (e.g. l.42 \includegrphics). Either the command is misspelled, or it belongs to a package you have not loaded (for example \includegraphics needs \usepackage{graphicx}, \textcolor needs \usepackage{xcolor}).

Example

% Wrong — package not loaded:
\textcolor{red}{Hi}        % Error if xcolor missing

% Fix — load the package in the preamble:
\usepackage{xcolor}
% ...
\textcolor{red}{Hi}

Frequently asked questions

How do I find which command caused it?

LaTeX prints the line number and the command, e.g. "l.42 \includegrphics". Go to that line and check the command right before the cursor position shown.

Which package defines this command?

Search the command name plus "latex package". Common ones: \includegraphics → graphicx, \textcolor → xcolor, \toprule → booktabs, \href → hyperref, \SI → siunitx.

Try the fix in LetX

Open the editor, paste your code, and compile in 1–2 seconds to see the error clear — free, in your browser.

Open LetX Free