← Back to blog

Blog & updates

Fix TikZ Option clash for package xcolor — Beamer, tikz, and template conflicts

2026-05-22

Why 'Option clash for package xcolor' happens when tikz, Beamer, and pgfplots coexist, how to fix load order, and how DrawFig export fits a clean preamble.

Fix TikZ Option clash for package xcolor

Published: 2026-05-22 Category: Tutorial / LaTeX figures Reading time: ~5 min Tags: TikZ compile errors, xcolor option clash, Beamer, drawfig, LaTeX figures
The full error often looks like:
! LaTeX Error: Option clash for package xcolor.
If you search “tikz xcolor option clash” or “beamer xcolor conflict”, the figure is usually fine — xcolor was loaded twice with different options in the preamble. tikz, pgfplots, Beamer, and university templates all touch xcolor indirectly.
📌 Other 6 TikZ compile issues: TikZ won't compile? Seven common errors

One-sentence cause

LaTeX allows each package only once. If you \usepackage[dvips]{xcolor} early and something later does \usepackage[xetex]{xcolor}, you get Option clash. Common setups:
  • Beamer themes already load xcolor; you add \usepackage{tikz} or load xcolor again manually
  • Journal .cls loads xcolor; the body adds options again
  • Engine mismatch — pdfLaTeX / XeLaTeX / LuaLaTeX vs pdftex / xetex / luatex options on xcolor

Recommended fix order

1. Load xcolor once, early, with engine-matched options

Place \usepackage{xcolor} right after \documentclass, before other drawing packages:
\documentclass{article}
% pdfLaTeX:
\usepackage[pdftex]{xcolor}
% XeLaTeX:  \usepackage[xetex]{xcolor}
% LuaLaTeX: \usepackage[luatex]{xcolor}

\usepackage{tikz}

2. Do not repeat \usepackage{xcolor}

Check for:
  • Template-provided xcolor
  • Your own \usepackage[table]{xcolor}
  • Indirect loads via pgfplots libraries
If the template already loaded it, remove your duplicate line and use the template's color commands.

3. Beamer only: \PassOptionsToPackage (use with care)

Only when the template docs allow it — before \documentclass:
\PassOptionsToPackage{dvipsnames}{xcolor}
\documentclass{beamer}
Templates differ by institution; back up main.tex before changing.

Relation to the figure itself

With an xcolor clash, the whole PDF fails — sometimes before tikzpicture runs. After fixing the preamble, if the figure still errors, check missing semicolon or missing tikzlibrary.

DrawFig recommendation

Set colours and line styles on the DrawFig canvas; Export TikZ generates style code for you, reducing hand-written \definecolor tangled with package options. Paste into a preamble where xcolor load order is already fixed, then one final compile. Pricing: Canvas editing and SVG/PNG/PDF export are free, no sign-in. TikZ export is 3 credits/use (sign-in; 30 credits/day). Details: credits rules.

Summary

  • Option clash for package xcolor = duplicate load or conflicting options — not a bad \draw.
  • Rule of thumb: one engine option, one load, as early as possible.
  • Full error map: TikZ compile failures — 7 categories.