# \frac

Standard fractions in mathematical expressions, derivations, and formulas.

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

## Metadata

| Field | Value |
| --- | --- |
| Topic | [Fractions and roots](https://texform.dev/latex/topics/fractions-roots) |
| Packages | ams, base |
| Allowed mode | math |
| Tags |  |
| Commonality | high |
| Kind | prefix |

## Syntax

### ams

Argument specification: `m m`

Standard fractions in mathematical expressions, derivations, and formulas.

### base

Argument specification: `m m`

Used for fractions in mathematical expressions and derivations

## Common tasks

### How to write a fraction with large operands

Use \dfrac when the fraction should stay display-sized.

```latex
\dfrac{a}{b}
```

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

### How to write a compact inline fraction

```latex
\tfrac{a}{b}
```

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

### How to write a nested fraction

```latex
\frac{1+\frac{a}{b}}{1-\frac{a}{b}}
```

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

### How to write a derivative as a fraction

```latex
\frac{dy}{dx}
```

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

## Examples

```latex
\frac{a}{b}
```

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

```latex
\frac12
```

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

## Package variants

| Package | Argument specification | Allowed mode | Description |
| --- | --- | --- | --- |
| ams | m m | math | Standard fractions in mathematical expressions, derivations, and formulas. |
| base | m m | math | Used for fractions in mathematical expressions and derivations |

## Renderer support

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

## Usage frequency

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

## In TeXForm

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

## Equivalent forms

```latex
\genfrac{}{}{}{}{#1}{#2}
```

exact. This is the AMS mapping's fixed-parameter specialization of \genfrac with empty delimiters, empty thickness, and empty style.

```latex
a \over b
```

approximate. \over is an infix primitive with different grouping scope; \frac is preferred in LaTeX

```latex
{a \over b}
```

exact. Primitive infix form (discouraged in modern LaTeX)

```latex
\dfrac{a}{b}
```

approximate. Forces display style

## See also

- [\\binom](https://texform.dev/latex/commands/binom)
- [\\dbinom](https://texform.dev/latex/commands/dbinom)
- [\\dfrac](https://texform.dev/latex/commands/dfrac)
- [\\genfrac](https://texform.dev/latex/commands/genfrac)
- [\\tbinom](https://texform.dev/latex/commands/tbinom)
- [\\tfrac](https://texform.dev/latex/commands/tfrac)

## Test cases

### ams

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

### base

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