# \color

Switches the current color for the rest of the enclosing group, used to highlight terms in a formula; an optional model argument such as rgb, RGB, or gray gives the color numerically.

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

## Metadata

| Field | Value |
| --- | --- |
| Packages | color |
| Allowed mode | both |
| Tags | presentation |
| Commonality | medium |
| Kind | declarative |

## Syntax

### color

Argument specification: `o:N m:N`

Switches the current color for the rest of the enclosing group, used to highlight terms in a formula; an optional model argument such as rgb, RGB, or gray gives the color numerically.

## Examples

```latex
{\color{red} x} + y
```

[Open in Playground](https://play.texform.dev/?input=%7B%5Ccolor%7Bred%7D+x%7D+%2B+y)

```latex
a + {\color{blue} b + c} = d
```

[Open in Playground](https://play.texform.dev/?input=a+%2B+%7B%5Ccolor%7Bblue%7D+b+%2B+c%7D+%3D+d)

```latex
{\color[rgb]{0.2,0.4,0.8} \sum_{i=1}^{n} x_i}
```

[Open in Playground](https://play.texform.dev/?input=%7B%5Ccolor%5Brgb%5D%7B0.2%2C0.4%2C0.8%7D+%5Csum_%7Bi%3D1%7D%5E%7Bn%7D+x_i%7D)

```latex
x + {\color[gray]{0.5} \varepsilon}
```

[Open in Playground](https://play.texform.dev/?input=x+%2B+%7B%5Ccolor%5Bgray%5D%7B0.5%7D+%5Cvarepsilon%7D)

## Renderer support

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

## Usage frequency

0.01% of formulas in the measured corpus contain this entry, rank 166 of 263 entries with frequency data.

## In TeXForm

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

## Test cases

### color

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| {\color{red} a} | Positive: baseline | Pass | Pass | Pass |
| {\color[rgb]{1,0,0} a} | Positive: vary:o[0] | Pass | Fail | Pass |
| {\color[\alpha]{1,0,0} a} | Negative: neg:N[0] | Fail | Fail | Fail |
| {\color{\alpha} a} | Negative: neg:N[1] | Pass | Fail | Fail |
