Option Clash Errors of LaTeX xcolor
Package Caused by Simultaneously Importing xcolor
Package and Other Packages
Jan. 05, 2025 • Updated May. 23, 2025
Import xcolor
package and showframe
package
If we import \usepackage{showframe}
first and then \usepackage[x11names]{xcolor}
:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{lipsum}
\usepackage{showframe}
\usepackage[x11names]{xcolor}
\pagecolor{AntiqueWhite1}
\begin{document}
\vspace*{\fill}
\lipsum[1-2]
\vspace*{\fill}
\end{document}
an option clash error will occur:
1
2
line 7: Option clash for package xcolor. \pagecolor
line 7: Package xcolor Error: Undefined color `AntiqueWhite1'. \pagecolor{AntiqueWhite1}
This error is caused by the x11names
option of xcolor
package.
Conversely, if we change the order of the both:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{lipsum}
\usepackage[x11names]{xcolor}
\usepackage{showframe}
\pagecolor{AntiqueWhite1}
\begin{document}
\vspace*{\fill}
\lipsum[1-2]
\vspace*{\fill}
\end{document}
the file will be compiled normally:
Import xcolor
package and tikz
package
Similarly, in the preamble if we import tikz
package first and then xcolor
package with the svgnames
option, an option clash will occur, for example:
1
2
3
4
5
6
7
8
9
\documentclass{article}
\usepackage{tikz}
\usepackage[svgnames]{xcolor}
\begin{document}
$\colorbox{DarkOrchid}{text}$
\end{document}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
! LaTeX Error: Option clash for package xcolor.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.4
The package xcolor has already been loaded with options:
[]
There has now been an attempt to load it with options
[svgnames]
Adding the global options:
,svgnames
to your \documentclass declaration may fix this.
Try typing <return> to proceed.
...
As can be seen from the log, it is because that the tikz
package has incorporated the xcolor
package with no option.
So, interchanging the order will solve this problem:
1
2
3
4
5
6
7
8
9
\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\begin{document}
$\colorbox{DarkOrchid}{text}$
\end{document}
and at this time those built-in colors created by the svgnames
option are available.