# \cfrac

Used for continued fractions, with an optional alignment selector for the numerator and denominator within the fraction.

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

## Metadata

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

## Syntax

### ams

Argument specification: `o:N m m`

Used for continued fractions, with an optional alignment selector for the numerator and denominator within the fraction.

## Examples

```latex
\cfrac{1}{2}
```

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

```latex
\cfrac[l]{1}{2}
```

[Open in Playground](https://play.texform.dev/?input=%5Ccfrac%5Bl%5D%7B1%7D%7B2%7D)

```latex
\cfrac[r]{1}{2}
```

[Open in Playground](https://play.texform.dev/?input=%5Ccfrac%5Br%5D%7B1%7D%7B2%7D)

## Renderer support

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

## Usage frequency

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

## In TeXForm

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

### [ams/cfrac-to-frac](https://texform.dev/rules/ams/cfrac-to-frac)

Drop continued-fraction styling from centered AMS cfrac forms.

Level: equiv. Fidelity: math.

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

→

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

```latex
\cfrac{1}{2}
```

→

```latex
\frac{1}{2}
```

## Equivalent forms

```latex
\frac{#2}{#3}
```

approximate. \cfrac adds struts and adjusts textstyle spacing appropriate for continued fractions, while \frac obeys the current surrounding style

## Test cases

### ams

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \cfrac{a}{b} | Positive: ctx:basic | Pass | Pass | Pass |
| \cfrac[l]{a}{b} | Positive: ctx:align-left | Pass | Pass | Pass |
| \cfrac[r]{a}{b} | Positive: ctx:align-right | Pass | Pass | Pass |
