LaTeX Error: Option clash for package <name>
A package is loaded twice with different options, often because the class or another package loaded it first. Load it once, with all options.
Help centre › LaTeX errors › Commands and packages · Error: the build stops or the output is wrong
What the log says
! LaTeX Error: Option clash for package graphicx.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.4 \begin
{document}What it means
A package can be loaded only once. When a second \usepackage (or a \RequirePackage inside the class or another package) asks for the same package with options the first load did not have, LaTeX cannot apply them and stops. The line number usually points at the second load, or at \begin{document} when the clash is found there.
Causes and fixes
Most common first. Each example is a complete document; the first fails with this message, the second is the same document fixed.
1. Another package or the class already loaded it without your options
tikz and pgfplots load graphicx; many journal classes load hyperref, natbib, graphicx or geometry. Your later \usepackage with options then clashes. Pass the options before the package is first loaded, with \PassOptionsToPackage{options}{package} above \documentclass, or load your version first.
\documentclass{article}
\usepackage{tikz}
\usepackage[draft]{graphicx}
\begin{document}
Text.
\end{document}\PassOptionsToPackage{draft}{graphicx}
\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\begin{document}
Text.
\end{document}2. hyperref is loaded twice, or options are given to an already loaded hyperref
Keep a single \usepackage{hyperref} (or none, if the class loads it) and set its options with \hypersetup{…} after the packages, for example \hypersetup{colorlinks, linkcolor=blue} or \hypersetup{hidelinks}.
\documentclass{article}
\usepackage{hyperref}
\usepackage[colorlinks]{hyperref}
\begin{document}
See the \href{https://www.ctan.org}{archive}.
\end{document}\documentclass{article}
\usepackage{hyperref}
\hypersetup{colorlinks}
\begin{document}
See the \href{https://www.ctan.org}{archive}.
\end{document}3. The same package appears twice in your own preamble
Long preambles collect duplicates. Search the preamble for the package name, merge the options into one \usepackage line and delete the other. For natbib loaded by the class, set the style with \setcitestyle{…} instead of a second load.
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage[a4paper]{geometry}
\begin{document}
Text.
\end{document}\documentclass{article}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage{amsmath}
\begin{document}
Text.
\end{document}Finding the line when the line number does not help
- The package named in the message is the one loaded twice. Search the preamble for it; if it appears only once, the class or a package loaded above it (tikz for graphicx, a journal class for hyperref or natbib) is the first load.
In Manulyx
The editor shows the error on the \usepackage line that clashes and offers a one-click Fix: for hyperref it moves the options into \hypersetup{…}, for natbib into \setcitestyle{…}, and for other packages it comments out the second load.
Write in Manulyx for free · Journal templates
More in commands and packages
- Undefined control sequence.LaTeX met a command it does not know: usually a typo, or a command whose package is not loaded. The log's l. line ends with the culprit.
- Missing number, treated as zero.A command that needs a number or length (\vspace, \setcounter, a width) got a word or nothing. Give it a value such as 1em or 3.
- LaTeX Error: Command \<name> already defined.\newcommand or a package tried to define a name that already exists. Pick another name, use \renewcommand, or drop the clashing package.
- Illegal parameter number in definition of \<name>.A # in a definition does not refer to a declared argument: #1 without [1], #1 in an environment's end code, or a # in a URL. Fix the count or escape it.
- Use of \<name> doesn't match its definition.A command with a special argument syntax, such as \put(x,y) or a \def with delimiters, was called without that syntax. Follow its exact form.
- LaTeX Error: Environment <name> undefined\begin{…} names an environment no loaded package defines: load the package (amsmath for align), fix the spelling, or define it with \newtheorem.
Every example on this page was compiled with pdfLaTeX to check that it fails and is fixed as described. All LaTeX errors