# \colorbox

Places text, optionally with inline math, on a colored background to highlight a short note or result; an optional model argument gives the background color numerically.

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

## Metadata

| Field | Value |
| --- | --- |
| Packages | color |
| Allowed mode | both |
| Tags | presentation |
| Commonality | low |
| Kind | prefix |

## Syntax

### color

Argument specification: `o:N m:N m:T`

Places text, optionally with inline math, on a colored background to highlight a short note or result; an optional model argument gives the background color numerically.

## Examples

```latex
\colorbox{yellow}{key step}
```

[Open in Playground](https://play.texform.dev/?input=%5Ccolorbox%7Byellow%7D%7Bkey+step%7D)

```latex
\colorbox{yellow}{$x^2 + y^2 = r^2$}
```

[Open in Playground](https://play.texform.dev/?input=%5Ccolorbox%7Byellow%7D%7B%24x%5E2+%2B+y%5E2+%3D+r%5E2%24%7D)

```latex
\colorbox[gray]{0.9}{for all $n \ge 1$}
```

[Open in Playground](https://play.texform.dev/?input=%5Ccolorbox%5Bgray%5D%7B0.9%7D%7Bfor+all+%24n+%5Cge+1%24%7D)

## Renderer support

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

## Usage frequency

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

## In TeXForm

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

## Test cases

### color

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \colorbox{yellow}{a} | Positive: baseline | Pass | Pass | Pass |
| \colorbox[gray]{0.85}{a} | Positive: vary:o[0] | Pass | Fail | Pass |
| \colorbox{yellow}a | Positive: bare[2] | Pass | Pass | Pass |
| \colorbox[\alpha]{0.85}{a} | Negative: neg:N[0] | Fail | Fail | Fail |
| \colorbox{\alpha}{a} | Negative: neg:N[1] | Pass | Fail | Fail |
| \colorbox{yellow}{a^2} | Negative: neg:T[2] | Pass | Fail | Fail |
