Fix the LaTeX error: environment subfigure undefined.
The error ! LaTeX Error: Environment subfigure undefined appears when your document calls \begin{subfigure} without loading the package that defines it, or when conflicting packages cancel each other out.
The short answer: add \usepackage{subcaption} to your preamble, remove old packages like subfigure or subfig, and use \begin{subfigure}[b]{0.3\textwidth} inside a standard figure environment.
Why the subfigure environment fails
LaTeX does not include multi-figure layouts in its base article class. You have to load a package that provides them, and each package uses its own syntax and command set.
The error occurs for three main reasons: you forgot to include the required package entirely, you loaded an old and deprecated package like subfigure, or you mixed commands from different packages in the same document.
How to fix the error
Follow these steps to clean up your figure packages and get your document compiling cleanly.
1. Load the modern subcaption package
Replace any old or conflicting packages with subcaption. It is the modern standard for multi-figure layouts and works with both pdfLaTeX and XeLaTeX on TeX Live 2026.
2. Remove outdated packages
Do not load subfigure or subfig alongside subcaption. They conflict with each other and trigger undefined control sequence errors or missing number errors during compilation.
3. Use the correct syntax
Wrap your subfigures inside a standard figure environment, set widths relative to \textwidth, and separate them with \hfill or \hskip to space them across the page.
A working multi-figure example
Here is a complete, minimal example that places three figures side by side without errors:
Minimal working code
Copy this structure into your document when you need side-by-side images with individual captions.
Questions
Why does my code work locally but fail on journal submission?
Journals often use older TeX Live distributions or strict class files that lack modern package versions. Check their template instructions and ensure you load standard packages like subcaption.
Can I use \subfloat with the subcaption package?
Yes, version 1.3 and newer of the subcaption package supports \subfloat. However, if you load the older subfig package at the same time, compilation will fail with undefined control sequence errors.
What is the difference between subfigure and subcaption?
Try your own paper in Texeno.
Start free, upload a project as a .zip and press Recompile. Upgrade when you need longer compiles.
Start writing