How to write a fraction in LaTeX

Use \frac{numerator}{denominator}in math mode. It is part of core LaTeX.

fraction.tex
\documentclass{article}
\begin{document}
Inline: $\frac{1}{2}$.

Display:
\[
\frac{a + b}{c}
\]
\end{document}

Both arguments need braces unless they are a single character. Inline, LaTeX shrinks the fraction to fit the line. In display math it draws it at full size.

The fraction commands

CommandPackageResult
\frac{a}{b}coreSize follows the context: small inline, full in display.
\dfrac{a}{b}amsmathAlways display size.
\tfrac{a}{b}amsmathAlways text (small) size.
\cfrac{a}{b}amsmathContinued fractions, full size at every level.
\binom{n}{k}amsmathBinomial coefficient, no bar.
a/bcoreSlashed, for inline use.

Forcing the size

A tall fraction inside a sentence can push the lines apart. If you need it small in display math, or large in a sentence, use\tfrac or \dfrac. Both needamsmath.

sizes.tex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Text size: $\tfrac{1}{2}$, display size: $\dfrac{1}{2}$.
\end{document}

Nested fractions

Put one \frac inside another's argument. Inner fractions are set smaller each level, which gets hard to read after two.

nested.tex
\[
\frac{1 + \frac{1}{x}}{1 - \frac{1}{x}}
\]

For a continued fraction, \cfrac keeps every level at full size.

continued.tex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3}}}
\]
\end{document}

Slashed fractions in running text

Writing $a/b$ sets the slash on one line and keeps the line height even. This is the usual choice for a simple ratio or a unit such as m/s. Add parentheses when the numerator or denominator has more than one term: $(a+b)/c$. Thenicefrac package gives a diagonal fraction like ½ with \nicefrac{1}{2}.

Binomial coefficients

\binom{n}{k} draws n over k with no bar, in parentheses. It needs amsmath. Do not fake it with\frac.

binomial.tex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\binom{n}{k} = \frac{n!}{k!\,(n-k)!}
\]
\end{document}

Common mistakes

Templates that use this

Fractions are everywhere in problem sets and exams. Try themaths homework ormaths exam templates, or browse theassignment templates.

Related

Fractions often appear insidesums and integrals. To number and line up a chain of equations, seealigning equations. For a first document, read LaTeX for beginners, or start from an article template.