# \underline

Used to place an underline under a mathematical symbol or expression in formulas.

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

## Metadata

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

## Syntax

### base

Argument specification: `m`

Used to place an underline under a mathematical symbol or expression in formulas.

### textmacros

Argument specification: `m:T`

Used to underline a text fragment, including short words or grouped text in text-mode content.

## Common tasks

### How to underline a variable

```latex
\underline{x}
```

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

### How to underline a longer expression

```latex
\underline{a+b+c}
```

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

### How to underline a word in a label

```latex
\text{\underline{min}}
```

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

## Examples

```latex
\underline x
```

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

```latex
\text{\underline x}
```

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

```latex
\text{\underline{ab}}
```

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

## Package variants

| Package | Argument specification | Allowed mode | Description |
| --- | --- | --- | --- |
| base | m | math | Used to place an underline under a mathematical symbol or expression in formulas. |
| textmacros | m:T | text | Used to underline a text fragment, including short words or grouped text in text-mode content. |

## Renderer support

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

## Usage frequency

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

## In TeXForm

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

## See also

- [\\overbrace](https://texform.dev/latex/commands/overbrace)
- [\\overleftarrow](https://texform.dev/latex/commands/overleftarrow)
- [\\overleftrightarrow](https://texform.dev/latex/commands/overleftrightarrow)
- [\\overline](https://texform.dev/latex/commands/overline)
- [\\overparen](https://texform.dev/latex/commands/overparen)
- [\\overrightarrow](https://texform.dev/latex/commands/overrightarrow)
- [\\underbrace](https://texform.dev/latex/commands/underbrace)
- [\\underleftarrow](https://texform.dev/latex/commands/underleftarrow)
- [\\underleftrightarrow](https://texform.dev/latex/commands/underleftrightarrow)
- [\\underparen](https://texform.dev/latex/commands/underparen)
- [\\underrightarrow](https://texform.dev/latex/commands/underrightarrow)

## Test cases

### base

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \underline{a} | Positive: baseline | Pass | Pass | Pass |
| \underline a | Positive: bare[0] | Pass | Pass | Pass |

### textmacros

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