Math and Equations

How to Write Fractions in LaTeX with \frac and \dfrac

Write fractions in LaTeX with frac, dfrac and tfrac, nested and continued fractions, binomials, and small slanted fractions for inline text.

On this page
  1. Basic fractions
  2. \frac, \dfrac and \tfrac
  3. Nested and continued fractions
  4. Text inside a fraction
  5. Fractions in running text
  6. Binomial coefficients
  7. Common mistakes

Write a fraction with \frac{numerator}{denominator} inside math mode, as in $\frac{3}{4}$. Use \dfrac when you want full display size inside inline math or inside another fraction.

Basic fractions

The fraction $\frac{3}{4}$ sits inside the sentence.

\[
  \frac{a + b}{c + d}
\]

\frac, \dfrac and \tfrac

\frac picks its size from the context. In display math it is full size. In inline math it is smaller, so it does not stretch the line. amsmath adds two fixed-size variants:

  • \dfrac always uses display size.
  • \tfrac always uses text size.
Inline: $\frac{1}{2} + \frac{1}{3}$ and $\dfrac{1}{2} + \dfrac{1}{3}$.

The \dfrac pair is easier to read, but it adds more space between lines.

Nested and continued fractions

Fractions can sit inside other fractions. Use \dfrac for the inner fraction when it would otherwise shrink:

\[
  x = \frac{1}{1 + \dfrac{1}{x}}
\]

For continued fractions, use \cfrac from amsmath, which keeps every level at display size:

\[
  \varphi = 1 + \cfrac{1}{1 + \cfrac{1}{1 + \cdots}}
\]

Text inside a fraction

Words in a fraction need \text{} from amsmath, so they stay upright and keep their spacing:

\[
  \frac{\text{part}}{\text{whole}}
\]

Fractions in running text

Three options work in running text:

  • \sfrac{1}{4} from the xfrac package prints a slanted fraction.
  • \nicefrac{1}{4} from the nicefrac package prints a small fraction with a slanted bar.
  • A plain slash, 1/4, works for quick notes, but it can be ambiguous in complex expressions.

Both \sfrac and \nicefrac need their package loaded. Packages for mathematics lists them with the other math tools.

Binomial coefficients

Binomial coefficients use a related command. \binom{n}{k} is part of base LaTeX. amsmath adds \dbinom for display size and \tbinom for text size:

\[
  \binom{n}{k} = \frac{n!}{k!\,(n-k)!}
\]

Common mistakes

  • Missing braces: each argument of \frac needs its own braces, or the fraction takes the wrong part of the expression. Write \frac{a+b}{c}, not \frac a+b c.
  • \frac12 works, but braces are clearer: a single-character argument can skip braces, as in \frac12. Braces avoid confusion when the argument grows.
  • Old form: {a \over b} is a plain TeX form. \frac is clearer in LaTeX.
  • Missing $: \frac outside math mode gives a “Missing $ inserted” error. Wrap it in $...$ or \[...\].

Fractions often sit inside roots and brackets. See square roots and nth roots and sizing brackets and parentheses. For fractions inside a piecewise definition, see piecewise functions with cases.

The complete guide to math and equations

Advanced Mathematics in LaTeX: Operators, Theorems and Proofs
Read the guide

Keep exploring

Guides from other topics

All topics →