Fractions, roots, and binomial coefficients are the prototypical pieces of math typesetting that grow vertically beyond the height of the letters. The basic \frac automatically changes size according to where it sits (in running text or on its own display line). But it often does not give the look you intended, and that is where amsmath’s \dfrac, \tfrac, and \cfrac, the \binom family, and the slashed fractions \nicefrac / \sfrac come in. This page sorts out, one by one, what each produces, which package it needs, and when to choose which.
The basic fraction, `\frac`
The basic command for a fraction is \frac{numerator}{denominator}. This is a feature of core LaTeX — it works without loading amsmath. The first argument is the numerator and the second the denominator; LaTeX draws a horizontal bar (the vinculum) between them, setting the numerator above and the denominator below. For instance \frac{1}{2} gives one-half: 1 on top and 2 below, separated by the bar.
A key property of \frac is that its size changes automatically with the surrounding context (the style). In inline math embedded in text (text style), the numerator and denominator are set small and compact so as not to disturb the line height much. Put the same expression on its own display line (display style) with \[ … \] and it is set large, with room to breathe. The example below shows how the very same \frac{a+b}{c} differs inline versus in a display.
本文中では小さく組まれる: $\frac{a+b}{c}$ のように。
\[
\frac{a+b}{c}
\]The first prints as a restrained fraction that fits within the line; the second as a large fraction centered on its own line. Fractions can also be nested: write another \frac in the numerator or denominator to build a multi-level fraction. Note, though, that an inner nested fraction is set in a yet-smaller style than the one around it, so it grows harder to read the deeper you go.
\[
\frac{1}{1 + \frac{1}{x}}
\]Here a two-level fraction is set, with a further fraction \frac{1}{x} inside the denominator. Note that the inner \frac{1}{x} is set one step smaller than the outer one. When you want every level kept the same size in a deep nest, reach for \dfrac (next section) or the dedicated continued-fraction command \cfrac.
Forcing the size: `\dfrac` and `\tfrac`
The automatic sizing of \frac is sometimes inconvenient. You may want a fraction in running text shown at full display size rather than squashed small; or, conversely, you may want just one fraction inside a display kept compact. The commands that answer this “I want to fix the style” need are \dfrac and \tfrac, provided by the amsmath package (both require \usepackage{amsmath}).
According to the amsmath user’s guide, \dfrac is a convenient abbreviation for {\displaystyle\frac ... }, and \tfrac for {\textstyle\frac ... }. So \dfrac{…}{…} is always set at display size (a large fraction) regardless of where it sits, while \tfrac{…}{…} is always set at text size (a small fraction). The arguments are taken exactly as with \frac: first the numerator, then the denominator.
% プリアンブルで: \usepackage{amsmath}
本文中でもフルサイズの分数: $\dfrac{\partial f}{\partial x}$。
\[
\dfrac{1}{1 + \dfrac{1}{x}}
\]The inline \dfrac{\partial f}{\partial x} is set as a partial-derivative fraction at full display size even within the line of text (which, in return, pushes the line height open). In the display example, nesting \dfrac keeps the outer and inner fractions the same size, making it more readable than nesting \frac (where the inner one shrinks). A rough guide to choosing:
\frac**: the usual choice — when you want the natural size, left to the context.\dfrac**: when you want a fraction in running text shown full-size rather than squashed, or to keep every level of a nest the same size.\tfrac**: when you want just one fraction inside a display set small and compact (e.g. to treat it almost like an exponent or subscript).
Continued fractions, `\cfrac`
When you build a continued fraction — where the denominator carries yet another fraction, again and again — by nesting \frac, the type shrinks at every level until it collapses into illegibility. The command \cfrac{numerator}{denominator} from the amsmath package is purpose-built for this. It stacks each level all at display size, uniformly, so the size does not change however deep the nesting goes. Always use it for continued fractions.
% プリアンブルで: \usepackage{amsmath}
\[
x = 1 + \cfrac{1}{2 + \cfrac{1}{2 + \cfrac{1}{2 + \cdots}}}
\]This sets the continued fraction 1 + (a fraction …) with each \cfrac level stacked vertically all at the same size. The trailing \cdots is the centered three-dot ellipsis (…) signalling “and so on.” This is in marked contrast to writing the same thing with \frac, where each inner level would come out smaller.
The \cfrac command takes an optional alignment argument. In the words of the amsmath user’s guide, left or right placement of a numerator is specified by using \cfrac[l] or \cfrac[r] instead of \cfrac. [l] sets the numerator flush left and [r] flush right; with nothing given it is centered (the default). Because the width of the denominator changes from level to level in a continued fraction, this argument is handy when you want the numerators lined up horizontally.
\[
\cfrac[l]{1}{2 + \cfrac[l]{1}{2 + \cfrac[l]{1}{2}}}
\]In this example each numerator 1 is set flush to the left end of its fraction bar (by default it would sit centered).
Binomial coefficients, `\binom`
A binomial coefficient (the number of combinations) — “choose k from n” — is written as a bar-less vertical stack enclosed in round brackets. The command \binom{n}{k} from the amsmath package produces it: n above and k below, stacked without a bar, the whole wrapped in correctly sized parentheses ( ). Unlike \frac, no fraction bar is drawn.
Just as \frac has \dfrac / \tfrac, \binom has size-fixing companions: \dbinom{n}{k} is always set at display size and \tbinom{n}{k} always at text size. Both require amsmath.
% プリアンブルで: \usepackage{amsmath}
\[
\binom{n}{k} = \frac{n!}{k!\,(n-k)!}
\]This is an equation with, on the left, a binomial coefficient (n over k) wrapped in large round brackets, and on the right a fraction of factorials (n! divided by k!(n−k)!). The \, on the right is the thin-space command inserting a small gap between the factorials.
Older sources, and plain-TeX style, sometimes write a binomial coefficient as {n \choose k}. That uses TeX’s generalized-fraction primitive, but today the **standard is amsmath’s \binom**. The related \over, \atop, and \above (generalized fractions with a bar / without a bar / with a specified rule thickness) are likewise made to emit warnings once amsmath is loaded, and the guide urges using \frac or \genfrac instead. \genfrac{left-delim}{right-delim}{thickness}{style}{numerator}{denominator} is amsmath’s general command for controlling the appearance of these fractions and binomials all at once; \frac, \binom, and \cfrac are all built on top of this machinery.
Roots: `\sqrt` and nth roots
A square root is set with \sqrt{contents}. This is a feature of core LaTeX — amsmath is not needed. It prints a radical sign (√) with a horizontal bar (the vinculum) extending from its upper right to cover the whole of the contents. The radical and bar scale automatically to the height and width of the contents, so \sqrt{x} and \sqrt{x^2 + y^2} are each set at just the right size for what they contain.
An nth root (a cube root, and so on) is written \sqrt[n]{contents}, giving the index as an optional argument in square brackets. A small index n is set at the upper left of the radical sign. A cube root, for example, is \sqrt[3]{x+y}: a small 3 at the upper left of the radical, with x+y under the bar.
\[
\sqrt{x^2 + y^2}, \qquad \sqrt[3]{x+y}, \qquad \sqrt[n]{a}.
\]This outputs a square root with x²+y² under the radical, a cube root with 3 at its upper left, and an nth root with n at its upper left, separated by \qquad (a wide gap). If you ever need to nudge the position or size of the root index, amsmath also offers tuning commands in the form \sqrt[\leftroot{…}\uproot{…}n]{…}, but for ordinary use the default placement is fine.
Setting exponents (powers)
Exponents (powers) are set as superscripts with the caret ^. x^2 is “x squared,” with a small 2 at the upper right of x. This is a core-LaTeX feature; no package is required. When the exponent is more than one character, always group it in braces: x^{10} correctly gives “x to the tenth,” whereas x^10 is set, unintentionally, as “x to the first” followed by a separate 0.
Exponents, fractions, and roots often combine, and using the commands so far in a single formula looks like this. Making the scope explicit with braces is the key to correct typesetting.
\[
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\]This is the quadratic formula. It is set as a large fraction centered on its own line, with “−b ± √(b²−4ac)” in the numerator and “2a” in the denominator. The b^2 under the radical is a squared superscript, and \pm is the “±” (plus-or-minus) sign. For the details of putting a superscript and subscript on the same letter (e.g. x^2_i) and for fine spacing adjustments, see the separate page “Scripts & spacing.”
Slashed fractions: `\nicefrac` and `\sfrac`
Sometimes you want “one half” in running text set not as a vertical stack but small and slanted, as a/b (think of a unit like “1/2”). For this you can use \nicefrac{a}{b} from the **nicefrac package**. It sets the numerator and denominator staggered diagonally around a slash, fitting within the line without disturbing its height. This command is not available by default — it needs \usepackage{nicefrac} in the preamble.
A newer, recommended alternative is \sfrac{a}{b} from the **xfrac package**. CTAN’s own description of nicefrac states that nicefrac’s facilities are provided, in a cleaner way, by the xfrac package. \sfrac works in both text mode and math mode and adjusts its appearance to the font more carefully. For new documents, \usepackage{xfrac} with \sfrac is the safe choice.
% nicefrac の場合: \usepackage{nicefrac}
所要時間は約 \nicefrac{3}{4} 時間です。
% xfrac の場合(推奨): \usepackage{xfrac}
およそ $\sfrac{1}{2}$ に相当します。In each case 3/4 and 1/2 are set as small slashed fractions that fit within the line height of the text. A useful division of labor: \frac or \dfrac for fractions you want set tall, and \sfrac (or \nicefrac) for ones you want shown small and slanted within the line.
| Command | Package needed | What it produces |
|---|---|---|
\frac{a}{b} | None (core LaTeX) | Fraction with a bar; size follows context |
\dfrac{a}{b} | amsmath | Fraction always at display size |
\tfrac{a}{b} | amsmath | Fraction always at text size |
\cfrac{a}{b} | amsmath | Continued fraction; levels stacked same-size; [l]/[r] align numerators |
\binom{n}{k} | amsmath | Bar-less binomial in parentheses (\dbinom/\tbinom too) |
\sqrt{x} | None (core LaTeX) | Square root; \sqrt[n]{x} for nth root |
\nicefrac{a}{b} | nicefrac | Small slashed fraction a/b |
\sfrac{a}{b} | xfrac | Small slashed fraction (modern alternative to nicefrac) |