FormaTeX
FatalCommands & Packages

Environment Undefined

! LaTeX Error: Environment XXX undefined.

What this error means

You tried to use \begin{envname} but LaTeX has no definition for that environment. Usually caused by a missing package or a typo in the environment name.

FormaTeX smart compile

FormaTeX smart compile detects AMS math environments and automatically adds \usepackage{amsmath} to the preamble before compiling.

Common causes

  • The package that provides the environment is not loaded
  • Typo in the environment name (e.g. \begin{aligend} instead of \begin{aligned})
  • Using an environment defined in a newer LaTeX version

How to fix it

Add the required \usepackage to the preamble. The amsmath package provides align, aligned, gather, multline, and most math environments. The enumitem package extends list environments.

Code examples

Causes the error
\documentclass{article}
% Missing \usepackage{amsmath}
\begin{document}

\begin{align}
  E &= mc^2 \\
  F &= ma
\end{align}

\end{document}
Fixed
\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{align}
  E &= mc^2 \\
  F &= ma
\end{align}

\end{document}

Related errors

Test the fix live

Paste your LaTeX into the playground and compile instantly.

One quick thing

We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.

Cookie policy