# \text

Inserting words or short phrases into mathematical expressions.

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

## Metadata

| Field | Value |
| --- | --- |
| Topic | [Boxes and text](https://texform.dev/latex/topics/boxes-text) |
| Packages | base, textmacros |
| Allowed mode | math, text |
| Tags |  |
| Commonality | high |
| Kind | prefix |

## Syntax

### base

Argument specification: `m:T`

Inserting words or short phrases into mathematical expressions.

### textmacros

Argument specification: `m:T`

## Common tasks

### How to insert a word in a formula

```latex
x=0 \text{ otherwise}
```

[Open in Playground](https://play.texform.dev/?input=x%3D0+%5Ctext%7B+otherwise%7D)

### How to write a cases condition

```latex
\begin{cases} x & \text{if } x\ge 0 \\ -x & \text{if } x<0 \end{cases}
```

[Open in Playground](https://play.texform.dev/?input=%5Cbegin%7Bcases%7D+x+%26+%5Ctext%7Bif+%7D+x%5Cge+0+%5C%5C+-x+%26+%5Ctext%7Bif+%7D+x%3C0+%5Cend%7Bcases%7D)

### How to write a subscript phrase that shrinks

\text scales in subscripts; \mbox does not.

```latex
T_{\text{max}}
```

[Open in Playground](https://play.texform.dev/?input=T_%7B%5Ctext%7Bmax%7D%7D)

## Examples

```latex
\text{a}
```

[Open in Playground](https://play.texform.dev/?input=%5Ctext%7Ba%7D)

```latex
\text b
```

[Open in Playground](https://play.texform.dev/?input=%5Ctext+b)

## Package variants

| Package | Argument specification | Allowed mode | Description |
| --- | --- | --- | --- |
| base | m:T | math | Inserting words or short phrases into mathematical expressions. |
| textmacros | m:T | text | — |

## Renderer support

| Package | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- |
| base | full | full | none |
| textmacros | none | full | none |

## Usage frequency

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

## In TeXForm

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

## Equivalent forms

```latex
\textnormal{#1}
```

exact. In MathJax base, both map directly to BaseMethods.HBox with no extra style or font arguments.

## See also

- [\\hbox](https://texform.dev/latex/commands/hbox)
- [\\mbox](https://texform.dev/latex/commands/mbox)
- [\\textbf](https://texform.dev/latex/commands/textbf)
- [\\textit](https://texform.dev/latex/commands/textit)
- [\\textnormal](https://texform.dev/latex/commands/textnormal)
- [\\textrm](https://texform.dev/latex/commands/textrm)
- [\\textsf](https://texform.dev/latex/commands/textsf)
- [\\texttt](https://texform.dev/latex/commands/texttt)
- [\\textup](https://texform.dev/latex/commands/textup)

## Test cases

### base

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \text{a} | Positive: baseline | Pass | Pass | Fail |
| \text a | Positive: bare[0] | Pass | Pass | Fail |
| \text{a^2} | Negative: neg:T[0] | Pass | Fail | Fail |

### textmacros

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \text{a} | Positive: baseline | Fail | Pass | Fail |
| \text a | Positive: bare[0] | Fail | Pass | Fail |
| \text{a^2} | Negative: neg:T[0] | Fail | Fail | Fail |
