# \hphantom

Used to reserve horizontal space in a mathematical formula corresponding to the argument, while taking up zero vertical space.

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

## Metadata

| Field | Value |
| --- | --- |
| Topic | [Spacing](https://texform.dev/latex/topics/spacing) |
| Packages | base, textmacros |
| Allowed mode | math, text |
| Tags | invisible, spacing |
| Commonality | medium |
| Kind | prefix |

## Syntax

### base

Argument specification: `m`

Used to reserve horizontal space in a mathematical formula corresponding to the argument, while taking up zero vertical space.

### textmacros

Argument specification: `m:T`

Used to horizontally offset equations or table cells by a specific piece of text's width without altering vertical flow.

## Examples

```latex
\hphantom{x}
```

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

```latex
\hphantom{abc}
```

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

```latex
\text{\hphantom{abc}}
```

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

## Package variants

| Package | Argument specification | Allowed mode | Description |
| --- | --- | --- | --- |
| base | m | math | Used to reserve horizontal space in a mathematical formula corresponding to the argument, while taking up zero vertical space. |
| textmacros | m:T | text | Used to horizontally offset equations or table cells by a specific piece of text's width without altering vertical flow. |

## Renderer support

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

## Usage frequency

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

## In TeXForm

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

## See also

- [\\phantom](https://texform.dev/latex/commands/phantom)
- [\\vphantom](https://texform.dev/latex/commands/vphantom)

## Test cases

### base

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

### textmacros

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