Support xcolor's optional color-model argument: `\color[rgb]{0.7,0,0}`
Author: graehlCreated Sep 30, 2026Updated Sep 30, 2026
KaTeX rejects xcolor's optional model argument, which is common in LaTeX written for papers and in LaTeXML output (e.g. arXiv HTML has it in the TeX anno.):
\color[rgb]{0.7,0,0}\times
KaTeX parse error: Invalid color: '[' at position 8The same applies to \textcolor[model]{spec}{…} and \colorbox[model]{spec}{…}.
Comes up a lot - rendering the math of 394 recent arXiv papers (38,871
expressions, KaTeX 0.18.7), this was the most frequent failure after
undefined author macros: 201 expressions, all \color[rgb]{…}.
Workaround until fixed: rewrite the source before calling KaTeX, converting the model and spec into the one-argument hex color format | model | spec | hex |
Source: KaTeX/KaTeX