I want to use color names like MidnightBlue in a style for a tikzpicture to e.g. fill it with a specific color, is this possible? Or am I limited to the other style (red!30 etc.)?

This MWE fails with Package xcolor Error: Undefined color MidnightBlue.:




\begin{tikzpicture}[myStyle/.style={rectangle, fill=MidnightBlue}]
    \node (test) [myStyle] { Test };         
  • @Qrrbrbirlbel Thanks, can you post that as an answer? Totally missed that tikz gets already loaded before.
    – Lennart
    Aug 11 at 11:38

1 Answer 1


The package tikz (by way of package pgfcore) loads the xcolor package.

In your case, the standalone class with the option tikz also loads the tikz package (and configurates other settings so that it works as intended). The \usepackage{tikz} has no effect anymore.

Thus, you need to say


or even just


in your preamble.

Without standalone you can just do

\documentclass{article}% or another that does not load TikZ

or, similarly as with standalone,


Similar problems arise with the beamer class, however this one has a class option xcolor that can be used to forward options only to the xcolor package (xcolor=dvipsnames) – and not to all packages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.