LaTeX error · Packages, files and fonts
LaTeX Error: Option clash for package amsmath.
Quick answer
LaTeX loads each package only once. If a package has already been loaded (by you, by the document class or by another package) and a later \usepackage asks for it again with options the first load did not have, LaTeX cannot apply them and stops with an option clash. Load the package once with all the options it needs, or put \PassOptionsToPackage{options}{package} before the first package that loads it.
The error in the log
This is how the message appears in the .log file (and in the compile output). The line starting with l. is the line number where TeX noticed the problem; the real mistake is there or just before it.
! LaTeX Error: Option clash for package amsmath.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.4 \begin
{document}Why it happens
- Another package loads it first without options:
mathtoolsloadsamsmath,tikzloadsxcolorandgraphicx,biblatexand many templates loadhyperref. - The document class already loads the package, and the preamble loads it again with options (common with journal and thesis classes and
hyperreforgeometry). - The same package appears twice in a long preamble, copied from two different sources, with different options each time.
How to fix it
Find who loads the package first. Search the log for the package file (here amsmath.sty): the file printed just before it is the one that loaded it.
Then either move your \usepackage[options]{package} above that package, give the options to the package that loads it (mathtools passes its options on to amsmath), or write \PassOptionsToPackage{fleqn}{amsmath} at the very top of the preamble, before \documentclass if the class is the one loading it.
Broken: reproduces the error
\documentclass{article}
\usepackage{mathtools} % loads amsmath without options
\usepackage[fleqn]{amsmath} % asks again with fleqn
\begin{document}
\[ E = mc^2 \]
\end{document}Try this in Octree — free LaTeX editor with AI, compiles in your browser
Fixed: compiles cleanly
\documentclass{article}
\usepackage[fleqn]{amsmath} % options on the first load
\usepackage{mathtools} % amsmath is already loaded: no clash
\begin{document}
\[ E = mc^2 \]
\end{document}Related errors
- Command \x already defined –
\newcommandused a name that a package or LaTeX already defines. - File not found – A package or class named in
\usepackageor\documentclassis misspelled or not installed. - Package babel Error: Unknown option – The language name given to babel is misspelled or its language file is not installed.
- All LaTeX errors and warnings – The full list, grouped by cause
Frequently Asked Questions
What does "Option clash for package" mean in LaTeX?
It means the package named in the message was already loaded, and a later \usepackage asked for it with options that were not used the first time. LaTeX never loads a package twice, so it cannot honour the new options and reports a clash.
How do I fix "Option clash for package hyperref" or "xcolor"?
Those two are usually loaded early by the class or by another package (for example tikz loads xcolor). Put \PassOptionsToPackage{table,dvipsnames}{xcolor} or the hyperref options at the top of the file, before \documentclass, or use \hypersetup{...} after hyperref is loaded instead of passing options again.
Can I just ignore an option clash?
Pressing Enter lets LaTeX continue, but the options you asked for are not applied, so the result is not what you wanted. Fix the loading order instead; it is usually a one-line change.
Does loading the same package twice without options cause an error?
No. A second \usepackage{name} with no options, or with a subset of the options already used, is silently ignored. The clash only happens when the second load asks for an option the first did not use.
Paste your document into Octree — compile errors get a Fix with AI button
When a compile fails, Octree shows the error next to the line that caused it and offers a one-click fix that you can review before applying. Free, nothing to install.
Fix it in Octree →