[Tex/LaTex] undefined control sequence \definecolor

errors

I added \definecolor{bg}{HTML}{282828} to my .tex file and now latex --shell-escape file.tex is breaking with less-than-helpful error messages.

File.tex looks like:

\documentclass[varwidth=40cm,border=2mm]{standalone}

\usepackage{minted}
\usemintedstyle{solarized}
\definecolor{bg}{HTML}{282828}

\begin{document}
\begin{LARGE}
  \inputminted{filetype}{example}
\end{LARGE}
\end{document}

(note my shell script changes {filetype} and {example} to appropriate values)

The error message says

! Undefined control sequence.
l.5 \definecolor
                {bg}{HTML}{282828}
?

! LaTeX Error: Missing \begin{document}.

But as you can see \begin{document} is not actually missing.

I see lots of other questions about "undefined control sequence" but don't understand what it's actually about nor what it means in this context.

Best Answer

An "undefined control sequence" means you're using a control sequence (or macro) that doesn't exist. \definecolor is defined within the color package. It's included when using xcolor. So, add \usepackage{xcolor} to your preamble before using \definecolor:

%...
\usepackage{xcolor}
\definecolor{bg}{HTML}{282828}
%...