# \hspace

Manual horizontal spacing around symbols or subexpressions in math formulas.

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

## Metadata

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

## Syntax

### base

Argument specification: `s m:L`

Manual horizontal spacing around symbols or subexpressions in math formulas.

### textmacros

Argument specification: `s m:L`

Used to insert explicit horizontal space in text documents and layouts.

## Examples

```latex
\hspace{1em}
```

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

```latex
\hspace*{1em}
```

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

```latex
\text{a\hspace{1em}b}
```

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

```latex
\text{a\hspace*{1em}b}
```

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

## Package variants

| Package | Argument specification | Allowed mode | Description |
| --- | --- | --- | --- |
| base | s m:L | math | Manual horizontal spacing around symbols or subexpressions in math formulas. |
| textmacros | s m:L | text | Used to insert explicit horizontal space in text documents and layouts. |

## Renderer support

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

## Usage frequency

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

## In TeXForm

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

## Equivalent forms

```latex
\hskip #1
```

exact. Both names are mapped directly to the same MathJax parse method with no extra parameters.

```latex
\hskip #1
```

approximate. Plain TeX primitive.

## See also

- [\\hskip](https://texform.dev/latex/commands/hskip)
- [\\kern](https://texform.dev/latex/commands/kern)
- [\\mkern](https://texform.dev/latex/commands/mkern)
- [\\mskip](https://texform.dev/latex/commands/mskip)
- [\\mspace](https://texform.dev/latex/commands/mspace)

## Test cases

### base

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \hspace{1pt} | Positive: baseline | Pass | Pass | Pass |
| \hspace*{1pt} | Positive: vary:s[0] | Fail | Pass | Pass |
| \hspace 1pt | Positive: bare[1] | Pass | Fail | Fail |
| \hspace{a} | Negative: neg:L[1] | Fail | Fail | Fail |

### textmacros

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \hspace{1pt} | Positive: baseline | Pass | Pass | Pass |
| \hspace*{1pt} | Positive: vary:s[0] | Fail | Pass | Pass |
| \hspace 1pt | Positive: bare[1] | Pass | Fail | Fail |
| \hspace{a} | Negative: neg:L[1] | Fail | Fail | Fail |
