Fractions in LaTeX: Complete Guide to Mathematical Notation
Date Published

Fractions in LaTeX
Writing fractions in LaTeX is essential for any mathematical document. Here's everything you need to know: the basic \frac command, the display and text variants, fractions without a line, inline slashed fractions, nested fractions, and the sizing tricks that keep everything readable.
Most of the commands below live in the amsmath package, so start every document that uses fractions with \usepackage{amsmath} in the preamble. \frac itself is built into LaTeX, but \dfrac, \tfrac, \cfrac, \binom and \genfrac are not.
Quick answer: A LaTeX fraction is \frac{a}{b} in math mode, for example $\frac{1}{2}$. Use \dfrac{a}{b} for a full-size fraction and \tfrac{a}{b} for a small one (both need \usepackage{amsmath}). For a fraction in text like ½, use \sfrac{1}{2} from the xfrac package, or simply 1/2.
LaTeX Fraction Cheat Sheet: Copy-Ready Snippet
This complete document compiles as is and covers the fraction commands people search for most: \frac, \dfrac, \tfrac, \sfrac in text, a fraction in parentheses, \binom, a fraction without a line and a continued fraction.
1\documentclass{article}2\usepackage{amsmath} % \dfrac, \tfrac, \cfrac, \binom, \genfrac3\usepackage{xfrac} % \sfrac4\begin{document}5Basic: $\frac{a}{b}$, display size: $\dfrac{a}{b}$, text size: $\tfrac{1}{2}$67Fraction in text: add \sfrac{1}{2} cup of sugar, or $\sfrac{3}{4}$ in math89\[10x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}, \qquad11\left( \frac{a}{b} \right)^2, \qquad12\binom{n}{k}, \qquad13\genfrac{}{}{0pt}{}{a}{b}14\]1516\[17\cfrac{1}{1 + \cfrac{1}{1 + \cfrac{1}{1 + \cdots}}}18\]19\end{document}
Try this in Octree — free LaTeX editor with AI, compiles in your browser
Basic Fractions with \frac
The standard fraction command:
$\frac{numerator}{denominator}$
Examples:
$\frac{1}{2}$ — one half
$\frac{a}{b}$ — a over b
$\frac{x + 1}{x - 1}$ — expressions
The first argument is set above the line and the second below it. Both arguments can contain any math: $\frac{\partial f}{\partial x}$ gives a partial derivative and $\frac{d}{dx}$ the ordinary one.
Display Style Fractions (\dfrac)
For larger, more readable fractions:
$\dfrac{1}{2}$
Use \dfrac when fractions appear too small in inline math or subscripts.
Comparison:
$\frac{1}{2}$ vs $\dfrac{1}{2}$
The dfrac version is larger and clearer.
Text Style Fractions (\tfrac)
For smaller fractions in display equations:
$\tfrac{1}{2}$
Useful when you want compact fractions in display mode.
\dfrac vs \frac vs \tfrac (and \cfrac) Compared
LaTeX sets math in one of four styles: display, text, script and scriptscript. \frac picks the style from its context, which is why a fraction looks big in \[ ... \] and small between $...$. The variants override that choice:
\dfrac{a}{b}always uses display style, even inside a paragraph or a subscript.\tfrac{a}{b}always uses text style, even inside a displayed equation.\cfrac{a}{b}uses display style and adds extra vertical space so that a chain of fractions stays legible.
A typical inline sentence: The ratio $\dfrac{a}{b}$ grows — the fraction is full size, which also increases the line height. $\tfrac{1}{2}x$ is handy in display math when a leading constant should not dominate the equation.
Continued Fractions (\cfrac)
For nested fractions that extend:
$\cfrac{1}{1 + \cfrac{1}{1 + \cfrac{1}{1 + \cdots}}}$
The \cfrac command properly centers numerators in continued fractions.
You can also push each numerator to the left or right with an optional argument: \cfrac[l]{1}{1 + \cfrac[r]{1}{2}}. Note that \cfrac is designed for display math; in inline text it will look oversized.
Fraction Without a Line (\genfrac, binomials, stacked numbers)
Sometimes you need two things stacked vertically with no bar between them: binomial coefficients, Legendre symbols, index sets under a sum, or simply "a over b" with no division implied. LaTeX has several ways to write a fraction without a line.
\genfrac: the general fraction builder
\genfrac (from amsmath) is the command behind \frac, \dfrac, \tfrac and \binom. It takes six arguments:
\genfrac{left}{right}{thickness}{style}{numerator}{denominator}
- left and right are delimiters, or empty for none.
- thickness is the rule width;
0ptremoves the line entirely. - style is
0(display),1(text),2(script),3(scriptscript), or empty to inherit from the context.
So a fraction without the bar is:
$\genfrac{}{}{0pt}{}{a}{b}$
Other useful variants:
$\genfrac{(}{)}{0pt}{}{n}{k}$ — identical to \binom{n}{k}
$\genfrac{[}{]}{1pt}{0}{x}{y}$ — square brackets and a thick display-style bar
$\genfrac{}{}{0pt}{1}{a}{b}$ — text-style stack, no line
If you use a stack repeatedly, give it a name in the preamble: \newcommand{\stack}[2]{\genfrac{}{}{0pt}{}{#1}{#2}}.
Binomial Coefficients
Using \binom:
$\binom{n}{k} = \frac{n!}{k!(n-k)!}$
Examples:
$\binom{5}{2} = 10$
$\binom{n}{0} = 1$
Like \frac, \binom has sized versions: \dbinom{n}{k} forces display style and \tbinom{n}{k} forces text style, which is handy when a binomial appears inline.
\substack for multi-line subscripts
When a sum or product needs conditions on two lines under it, use \substack:
$\sum_{\substack{i=1 \\ i \neq j}}^{n} a_i$
$\sum_{\substack{0 \le i \le m \\ 0 < j < n}} P(i,j)$
Each \\ starts a new line, and the lines are centered automatically in script size.
\atop and \choose: why they are deprecated
Plain TeX offers the infix primitives {a \atop b}, {n \choose k} and {a \over b}. They still compile, but amsmath logs the warning Foreign command \atop; \frac or \genfrac should be used instead whenever you use one. The problem is that an infix command takes everything to its left and right inside the current group as its arguments, so x + a \over b silently becomes (x + a)/b, and amsmath cannot reliably work out which style to apply. Use \genfrac{}{}{0pt}{}{a}{b} and \binom{n}{k} instead; they are explicit, nestable and style-safe.
\stackrel, \overset and \underset
To stack a small symbol on top of a relation, use \stackrel:
$x \stackrel{\text{def}}{=} y$
The first argument is set in script size above the second. amsmath generalizes this to any symbol with \overset and \underset:
$A \overset{f}{\longrightarrow} B$
$A \underset{g}{\longleftarrow} B$
These are not fractions, but they are the right tool when you want "something above something" rather than a true stacked pair.
Nested Fractions
Fractions within fractions:
$\frac{\frac{a}{b}}{\frac{c}{d}} = \frac{ad}{bc}$
For clarity, consider using:
$\frac{a/b}{c/d}$ — slash notation inside
Sizing nested fractions
Inner fractions are set one style smaller than their parent, so a fraction inside a fraction is text style, and the next level down is script style. Three fixes:
- Force the inner level back up:
$\frac{\dfrac{a}{b}}{\dfrac{c}{d}}$. - Put
\displaystyleinside the inline formula:$\displaystyle \frac{1}{1 + \frac{1}{x}}$sets the outer fraction at display size and the inner one at text size. - Use
\cfracfor genuine continued fractions, as shown above.
Parentheses around fractions
Static parentheses are too short for a fraction. Use \left( and \right) so they grow to fit:
$\left( \frac{a}{b} \right)^2$
$\left[ \frac{x+1}{x-1} \right]$
If the automatic size is slightly too tall, pick a size by hand with \Bigl( \frac{a}{b} \Bigr); the manual sizes run \bigl, \Bigl, \biggl, \Biggl with matching right-hand versions.
Partial Fractions
Common in calculus:
$\frac{1}{x^2-1} = \frac{1}{2(x-1)} - \frac{1}{2(x+1)}$
Fractions with Radicals
$\frac{1}{\sqrt{2}} = \frac{\sqrt{2}}{2}$
$\frac{a}{\sqrt{b}} = \frac{a\sqrt{b}}{b}$
Slashed Fractions
For inline use, sometimes slashes work better:
$1/2$ — simple slash
$a/b$ — variables
Use the nicefrac package for better-looking slashed fractions:
$\nicefrac{1}{2}$
LaTeX Fraction in Text: \nicefrac and \sfrac
A stacked \frac in running text either looks tiny or pushes the lines apart. Two packages produce the compact diagonal fractions used in printed books:
\usepackage{nicefrac} then $\nicefrac{1}{2}$ or, in text mode, \nicefrac{3}{4}
\usepackage{xfrac} then $\sfrac{1}{2}$ or \sfrac{3}{4}
\nicefrac builds the fraction from a raised small numerator, a slash and a lowered denominator, and works with any font. \sfrac from xfrac is newer and better typeset: it scales the numerator and denominator in a font-aware way, kerns the slash correctly, can be configured per font family, and copes with longer arguments such as \sfrac{a+b}{c}. Both commands work in text mode as well as math mode, so you can write \sfrac{1}{2} cup of sugar in a recipe or a table without entering math.
Which to choose:
- Plain
1/2— fine for code listings, tables, and anywhere you want no typographic fuss. \nicefrac— quick, widely available, slightly cruder spacing.\sfrac— best looking, preferred for new documents.\tfrac— when you want a true horizontal bar but at text size.
Common Fraction Formulas
Quadratic Formula
$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$
Derivative Definition
$f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$
Euler's Identity
$e^{i\pi} + 1 = 0$ (no fractions, but iconic!)
Probability
$P(A|B) = \frac{P(B|A) \cdot P(A)}{P(B)}$
Styling Tips
Larger Fractions in Display
Use \displaystyle:
$\displaystyle \frac{1}{2}$
Smaller Fractions Inline
Use \textstyle:
$\textstyle \frac{1}{2}$
Spacing Around Fractions
Add space with \, or \;:
$x \, \frac{a}{b} \, y$
Fractional exponents
In an exponent a stacked fraction becomes unreadably small. Write $x^{1/2}$ rather than $x^{\frac{1}{2}}$, or use \sqrt{x}.
Quick Reference
Command | Package | Result | Typical use |
|---|---|---|---|
| LaTeX core | a over b, size from context | general purpose |
| amsmath | always display size | inline fractions that must stay large |
| amsmath | always text size | compact fractions in display math |
| amsmath | display size with extra spacing | continued fractions |
| amsmath | stacked, no line | fraction without a bar |
| amsmath | stacked in parentheses | binomial coefficients |
| amsmath | two-line script-size stack | sum and product limits |
| nicefrac | diagonal a/b | inline fractions in text |
| xfrac | diagonal a/b, font-aware | inline fractions in text |
| LaTeX core | small a above a relation | definitions, labelled arrows |
| none | plain slash | code, tables, exponents |
Common Errors with LaTeX Fractions
Wrong: $\frac12$ (missing braces)
Right: $\frac{1}{2}$
\frac12 happens to compile because each argument is a single character, but it breaks as soon as an argument grows: \frac10 gives 1 over 0, not 10 over something. Always use braces.
Wrong: Nested fractions getting too small
Fix: Use \dfrac for inner fractions
Wrong: \dfrac or \binom reported as an undefined control sequence
Fix: Add \usepackage{amsmath} to the preamble
Wrong: (\frac{a}{b}) with parentheses that are too short
Fix: \left( \frac{a}{b} \right)
Error: ! Missing $ inserted. \frac was typed in a normal sentence. Fix: fractions are math, so write $\frac{1}{2}$, or use \sfrac{1}{2} (xfrac), which also works in text mode.
Error: ! Undefined control sequence \sfrac (or \nicefrac). Fix: load the package that defines it: \usepackage{xfrac} for \sfrac, \usepackage{nicefrac} for \nicefrac.
Error: ! Missing } inserted or ! Extra }. The braces of \frac{...}{...} are unbalanced, as in \frac{a+1}{b. Fix: give each argument exactly one opening and one closing brace: \frac{a+1}{b}.
LaTeX Fractions FAQ
How do I make a fraction in LaTeX?
Enter math mode and write \frac{numerator}{denominator}, for example $\frac{3}{4}$ for three quarters. Inside a displayed equation the fraction is set at full size; inside a sentence it is reduced, and you can write \dfrac instead to keep it large.
How do I write a fraction without the bar?
Use \genfrac{}{}{0pt}{}{a}{b} from amsmath. The third argument is the thickness of the line, and 0pt removes it. For a binomial coefficient use \binom{n}{k}, and for two-line limits under a sum use \substack{...}. Avoid the old \atop primitive, which amsmath flags as a foreign command.
How do I type ½ in LaTeX?
For a math fraction write $\frac{1}{2}$ or the inline \sfrac{1}{2}. For the single typographic character use \textonehalf in text mode (also \textonequarter and \textthreequarters). These symbols come from the textcomp package, which LaTeX has loaded automatically since the 2020 release; on older installations add \usepackage{textcomp}. With UTF-8 input you can also type the ½ character directly and LaTeX maps it to \textonehalf.
Why does my fraction look small inline?
Inline math uses text style, which shrinks fractions. Switch the fraction to \dfrac, add \displaystyle at the start of the formula, or move the expression into a display equation.
What is the difference between \frac and \dfrac?
\frac adapts its size to the surrounding style, while \dfrac always uses display size. In a display equation the two look identical; inline, \dfrac is larger and increases the line spacing around it.
What does \frac mean in LaTeX?
\frac is the LaTeX fraction command: \frac{numerator}{denominator} sets the first argument over the second with a horizontal bar. It works only in math mode and needs no package.
How do I write a fraction in text in LaTeX?
Inside a sentence use $\frac{1}{2}$ for a small stacked fraction, \sfrac{1}{2} (xfrac) for a slanted ½-style fraction, or plain 1/2. Use \dfrac inline only when the fraction must be full size, because it increases the line spacing.
How do I put a fraction in brackets?
Use auto-sizing delimiters: \left( \frac{a}{b} \right) or \left[ \frac{a}{b} \right]. See the LaTeX brackets and parentheses guide for manual sizes such as \bigl( and \Bigr).
Write Fractions with Octree
Octree makes fractions easy:
- Smart autocomplete for \frac
- Real-time preview
- AI suggests proper styling
- Export perfect PDFs
Try it at https://useoctree.com
Try this in Octree — free LaTeX editor with AI, compiles in your browser

Dot product in LaTeX: \vec{a} \cdot \vec{b}; cross product: \vec{a} \times \vec{b}. Vectors in LaTeX with \vec, \mathbf, the physics package, and common fixes.

What the phi symbol means: the golden ratio 1.618, φ vs ϕ, magnetic flux, the normal CDF, Euler's totient. How to type φ and Φ on Mac, Windows, LaTeX.