Fractions in LaTeX
Use \frac{num}{den} to write fractions in LaTeX.
Quick answer
latex
$\frac{1}{2}$ % inline fraction
\[ \frac{a + b}{c} \] % display fractionBasic syntax
\frac{numerator}{denominator} works in any math environment. Always enclose numerator and denominator in curly braces.
latex
\documentclass{article}
\begin{document}
Inline: $\frac{3}{4}$ of the students passed.
Display mode:
\[
\frac{a + b}{c + d}
\]
\end{document}Display vs. text size: \dfrac and \tfrac
By default, inline fractions are typeset smaller. Use \dfrac to force display (large) style inline, or \tfrac to force text (small) style in display mode. Both require the amsmath package.
latex
\usepackage{amsmath} % in preamble
% Force large fraction inline:
The answer is $\dfrac{1}{2}$.
% Force small fraction in display mode:
\[
\text{approximately } \tfrac{22}{7}
\]Nested fractions
You can nest \frac inside itself for compound fractions. Use \dfrac at the inner level to keep them readable.
latex
\[
\frac{\dfrac{1}{x} + y}{z}
\]
% Continued fraction:
\[
a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3}}}
\]\cfrac (from amsmath) is designed for continued fractions and keeps things nicely sized.
Fractions in equations
latex
\usepackage{amsmath}
\begin{equation}
\frac{\Delta y}{\Delta x} = \frac{f(x + h) - f(x)}{h}
\end{equation}
\begin{align}
P(A|B) &= \frac{P(B|A) \cdot P(A)}{P(B)}
\end{align}Common mistakes
✗
$\frac 1 2$— missing braces; may work for single chars but not reliable✓
$\frac{1}{2}$— always use braces