# \definecolor

Defines a named color from a model and a specification, such as RGB with 204,85,0, so that later color commands can refer to it by name; it produces no output itself.

https://texform.dev/latex/commands/definecolor

## Metadata

| Field | Value |
| --- | --- |
| Packages | color |
| Allowed mode | both |
| Tags | invisible, newdefine |
| Commonality | low |
| Kind | prefix |

## Syntax

### color

Argument specification: `m:N m:N m:N`

Defines a named color from a model and a specification, such as RGB with 204,85,0, so that later color commands can refer to it by name; it produces no output itself.

## Examples

```latex
\definecolor{accent}{RGB}{204,85,0}\textcolor{accent}{x} + y
```

[Open in Playground](https://play.texform.dev/?input=%5Cdefinecolor%7Baccent%7D%7BRGB%7D%7B204%2C85%2C0%7D%5Ctextcolor%7Baccent%7D%7Bx%7D+%2B+y)

```latex
\definecolor{myblue}{rgb}{0.1,0.3,0.7}{\color{myblue} \alpha + \beta}
```

[Open in Playground](https://play.texform.dev/?input=%5Cdefinecolor%7Bmyblue%7D%7Brgb%7D%7B0.1%2C0.3%2C0.7%7D%7B%5Ccolor%7Bmyblue%7D+%5Calpha+%2B+%5Cbeta%7D)

```latex
\definecolor{lightgray}{gray}{0.9}\colorbox{lightgray}{$a = b$}
```

[Open in Playground](https://play.texform.dev/?input=%5Cdefinecolor%7Blightgray%7D%7Bgray%7D%7B0.9%7D%5Ccolorbox%7Blightgray%7D%7B%24a+%3D+b%24%7D)

## Renderer support

| Package | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- |
| color | full | none | full |

## In TeXForm

TeXForm parses this entry as prefix syntax; the package determines its argument specification.

## Test cases

### color

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \definecolor{accent}{RGB}{255,128,0} | Positive: baseline | Pass | Fail | Pass |
| \definecolor{\alpha}{RGB}{255,128,0} | Negative: neg:N[0] | Pass | Fail | Pass |
| \definecolor{accent}{\alpha}{255,128,0} | Negative: neg:N[1] | Fail | Fail | Fail |
| \definecolor{accent}{RGB}{\alpha} | Negative: neg:N[2] | Fail | Fail | Fail |
