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.

Fails
\documentclass{article}
\usepackage{tikz}
\usepackage[draft]{graphicx}
\begin{document}
Text.
\end{document}
Fixed
\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}.

Fails
\documentclass{article}
\usepackage{hyperref}
\usepackage[colorlinks]{hyperref}
\begin{document}
See the \href{https://www.ctan.org}{archive}.
\end{document}
Fixed
\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.

Fails
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage[a4paper]{geometry}
\begin{document}
Text.
\end{document}
Fixed
\documentclass{article}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage{amsmath}
\begin{document}
Text.
\end{document}

Finding the line when the line number does not help

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

Every example on this page was compiled with pdfLaTeX to check that it fails and is fixed as described. All LaTeX errors