LatexNotes

Fractions in LaTeX

A fraction typesets a numerator stacked over a denominator, separated by a horizontal bar; in LaTeX it is written with \frac{numerator}{denominator}.

LaTeX command

\frac{a}{b}

Not the symbol you meant? Draw it to find the command →

The core command is \frac{a}{b}, which takes exactly two arguments: the first becomes the numerator, the second the denominator. Each argument is a group, so \frac{a+b}{c+d} keeps the whole sum in each position. For a single character you can drop the braces (\frac12), but bracing every argument is the safe habit that avoids surprises with multi-character numerators.

LaTeX sizes fractions by context. In an inline formula a \frac is shrunk to fit the line; in a displayed equation it is set full size. Force full size inline with \dfrac and force the small style with \tfrac. For stacked continued fractions use \cfrac, which keeps every level readable. These three variants come from the amsmath package, which is loaded by default in most documents and supported by KaTeX.

For a quick throwaway fraction you can just write a/b with a slash, which suits simple ratios and exponents. Reserve \frac for anything that benefits from a proper bar. Deeply nested \frac calls shrink quickly and become hard to read, so prefer \cfrac or a slashed form when nesting more than two levels.

Other forms

\dfrac{a}{b}display-size fraction inline
\tfrac{a}{b}text-size fraction
a/ba simple slashed fraction

Examples

$\frac{1}{2}$

a simple one-half

$\frac{a+b}{c+d}$

a compound fraction with sums top and bottom

$\dfrac{1}{2} \neq \tfrac{1}{2}$

display-size versus text-size inline

$\cfrac{1}{1+\cfrac{1}{x}}$

a continued fraction with \cfrac

$$x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}$$

a displayed fraction inside the quadratic formula

Tips and common mistakes

Working from handwritten notes?

LatexNotes turns a photo or PDF of handwritten mathematics into clean, compilable LaTeX - graphs and all. Free to try, no sign-up.

Convert your maths to LaTeX →

FAQ

How do I make a fraction full size in inline text?

Use \dfrac{a}{b} instead of \frac{a}{b}. It forces the displaystyle (large) fraction even on a normal text line.

What is the difference between \frac, \dfrac and \tfrac?

\frac follows the surrounding style (small inline, large in display). \dfrac is always the large display style; \tfrac is always the small text style.

How do I write a continued fraction?

Use \cfrac{1}{1+\cfrac{1}{x}}. Unlike nested \frac, \cfrac keeps every level at a readable size. It needs the amsmath package.

See also