How to Fix “Undefined Control Sequence” at \end{align*}
At a glance
- 1. Check the package
Load amsmath in the preamble with \usepackage{amsmath}.
- 2. Check the environment
Match \begin{align*} with \end{align*}, and keep the environment out of dollar signs.
- 3. Read the first error
Inspect the first compiler error and nearby source lines; later errors may be consequences.
- 4. Test a minimal file
Compile a short document containing only the preamble and one align* equation.
The align* environment is provided by the amsmath package. If LaTeX reports an undefined control sequence at \end{align*}, the usual fix is to load that package in the preamble. The line shown in the error may be where LaTeX notices a problem, rather than where the underlying mistake began, so check the matching \begin and the first error in the compiler log as well.
Load amsmath in the preamble
Add this line before \begin{document}:
\usepackage{amsmath}
Here is a complete minimal example that should compile with a standard LaTeX engine:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
x + y &= 10, \\
2x - y &= 2.
\end{align*}
\end{document}
The & marks the alignment point; in this example, the equals signs line up. The \\ ends the first row. The asterisk in align* means the equations are not numbered. You do not need to load amssymb just to use align*.
Put \usepackage{amsmath} in the preamble, not between \begin{document} and \end{document}. If you are using a document editor that manages packages for you, check that its generated preamble includes amsmath.
Check how the environment is used
align* is already a display-math environment. Do not wrap it in dollar signs or another display-math delimiter. This is incorrect:
$$
\begin{align*}
a &= b
\end{align*}
$$
Use the environment by itself:
\begin{align*}
a &= b
\end{align*}
Also verify that the opening and closing names match exactly. For example, \begin{align*} must be paired with \end{align*}, not \end{align}. A mismatch, a typo, or a missing opening line can cause errors that appear at the closing line.
Find the first error in the log
When a compiler reports an error at \end{align*}, it is tempting to assume the closing command itself is wrong. Often, however, TeX has been unable to set up the environment or has encountered an earlier syntax problem. Error recovery can produce additional messages, so start with the first error in the log and inspect the source just above its reported line.
For example, if amsmath is not loaded, LaTeX does not know the align* environment. Depending on the compiler and how it recovers, the useful message may refer to the environment’s beginning or may appear near its end. Adding the package is the standard fix.
If the package is already loaded, check these details:
- The spelling and punctuation in both environment commands, including the
*. - Whether the
\begin{align*}line is actually present before the reported\end{align*}. - Whether the environment has accidentally been placed inside
$...$,\(...\),\[...\], or another display-math environment. - Whether an earlier unmatched brace or environment has confused TeX’s parsing.
- Whether the document is being compiled as LaTeX rather than with a plain TeX format.
A useful debugging technique is to copy the relevant equation into the minimal example above and compile it. If that works, add the rest of your document back a piece at a time. This helps identify a conflicting or unmatched command in the larger file.
Common mistakes
Adding the package after the document begins. Package-loading commands belong in the preamble, before \begin{document}.
Mixing starred and unstarred names. align and align* are separate environments. Use the same spelling at both ends. The unstarred align numbers equations; align* does not.
Putting an alignment environment inside math delimiters. Do not use \begin{align*} inside $...$ or \[...\]. If you need only one unaligned displayed equation, use \[ ... \]; if you need an equation number, use equation instead.
Looking only at the last reported error. A later error can be a consequence of the first one. Fix the first relevant message, recompile, and then assess what remains.
If the minimal example compiles but your full document does not, the issue is likely elsewhere in the surrounding source or preamble—not an inherent problem with align*.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.