LaTeX "Undefined Control Sequence": Find and Fix the Command

How to read "! Undefined control sequence." in a TeX log, the six usual causes and their fixes, why a PDF can still come out, and what the error looks like in our LaTeX editor.

3 min read

Common causes of the LaTeX error Undefined control sequence and their fixes: a typo, a missing package, a command for another engine, a backslash in a path

Short answer: "! Undefined control sequence." means TeX met a command it doesn't know. Look at the line after it in the log, which starts with l. and a line number: the last command shown on that line is the unknown one. Usually it is a typo, a missing \usepackage, or a command that only exists in XeLaTeX or a newer package.

Eddocu runs its own TeX engine, and our LaTeX editor shows this error with its line. The fix itself is always in your source, as below.

How to read the error

A typical log looks like this:

! Undefined control sequence.
l.12 The angle is 90\degree
                             in the sketch.

TeX breaks the line where it stopped reading. The command just before the break, here \degree (which needs a package such as gensymb), is the one it doesn't know. When the error happens inside another macro, the log shows a few <argument> or <recently read> lines first; the culprit is the last command on the first of those lines.

The usual causes and fixes

CauseExampleFix
A typo\beign, \textbf written \textbgCorrect the spelling
A missing package\includegraphics without graphicx, \SI without siunitxAdd the \usepackage line to the preamble
A command from a newer package versionA macro your installation's package doesn't have yetUpdate the package, or use the older name
A macro defined in another fileA project's own \newcommand in a file that isn't loadedCheck the \input or the class file is there
A command for another engine\setmainfont from fontspec under pdfLaTeXCompile with XeLaTeX or LuaLaTeX, or remove it
A backslash in a path or URLC:\Users\me in the textUse forward slashes, \url or \textbackslash

Some more checks when the cause isn't clear:

  1. Delete the auxiliary files (.aux, .toc, .out) and compile again. A bad line saved from an earlier run can bring the error back after you fixed the source.
  2. Search the command on CTAN or in your package's manual to learn which package defines it.
  3. Comment out half the document when the line number points into a long macro or a class file, and narrow it down.

Why the PDF is sometimes made anyway

TeX can carry on after this error. It drops the unknown command and keeps reading, so in batch mode, which most editors use, you can get a PDF with that command simply missing: a symbol gone, a word unformatted. Don't ignore the error because a PDF came out; read the output where the line points.

What Eddocu shows

The LaTeX editor and LaTeX to PDF compile with pdfLaTeX in your browser, on a TeX engine of our own. It raises the same "Undefined control sequence" error and recovers the same way TeX does, so:

  • When the PDF is made anyway, the editor shows it with a notice, "The PDF was made, with these problems", and the error message under it. That list has no line number, so look for the missing output in the PDF.
  • When the run fails, it shows "TeX could not finish", the message, the source text from the log and the line number. In a single-file document the line number is a link to that line in the source.
  • When the document needs XeLaTeX or LuaLaTeX, such as one using fontspec, the editor says so instead of compiling, since it runs pdfLaTeX only.

The source stays on your device. Packages load from Eddocu's own TeX package files the first time a document needs them.

Facts checked on 2 December 2026 against Eddocu's TeX engine, its LaTeX import and the LaTeX editor's error display.

Questions

Which command is undefined?

The last command printed on the l. line of the log, just before the line break TeX inserts.

Why does it work on Overleaf but not on my computer?

The two installations have different package versions or a different compiler setting. Check the compiler in the project's settings, then update your local packages.

Can I just press Enter to continue?

In an interactive run, yes: TeX skips the command. The output will lack whatever that command should have done, so fix the source before you share the PDF.