The hook of the radical sign √ and the bar that runs across the top of it were invented 112 years apart. The bare hook appeared in print in 1525, in Christoff Rudolff’s Die Coss; it was Descartes, in 1637, who joined it to the overbar (the vinculum) to make the symbol we use now. The fraction bar is older still, traced to the twelfth-century Maghrebi mathematician al-Hassar and brought to Europe by Fibonacci. LaTeX still assembles those separately-born parts separately. This page reads fractions, roots and exponents starting from one fact: \frac is \over underneath. It covers how \dfrac, \tfrac, \cfrac, \binom and \genfrac divide the work, when to pick \nicefrac or \sfrac, and what to do about the real symptoms — a fraction that comes out too small, a root index sitting in the wrong place.
\frac is \over with braces around it
\frac belongs to the LaTeX kernel; amsmath is not required. The definition sits in plain sight at line 12700 of latex.ltx: \DeclareRobustCommand\frac[2]{{\begingroup#1\endgroup\over#2}}. Read it out and it says: wrap the whole thing in { }, seal the numerator inside \begingroup … \endgroup, and put TeX’s primitive \over between the two. So \frac{a+b}{c} and {a+b \over c} produce the same output. Measured on TeX Live 2024 at 10pt in Computer Modern, both boxes come out at exactly 24.19968pt wide, 13.70952pt high and 6.85951pt deep.
So why does everyone keep saying “use \frac, not \over”? The difference is the braces. \over is a primitive, and it swallows everything to its left in the current group as the numerator. That is why {x + y \over 2} is not “x plus y-over-2” but (x+y)/2, while x + \frac{y}{2}, written with the same intent, correctly gives x + y/2. \frac prevents that accident structurally, by taking the numerator as an explicit argument. Put two \over in one group and TeX cannot decide which to do first: it stops with ! Ambiguous; you need another { and }.
% same shape in the source, two different formulas
\[
{x + y \over 2} \qquad x + \frac{y}{2}
\]
% error: Ambiguous; you need another { and }.
% \[ 1 \over 2 \over 3 \]Loading amsmath makes this policy explicit in code. amsmath.sty first stashes the primitive with \@saveprimitive\over\@@over, then replaces \over, \atop and \above (and their …withdelims forms) so that using one emits Package amsmath Warning: Foreign command \over; \frac or \genfrac should be used instead. It then redefines \frac itself, at line 234, as {{\begingroup#1\endgroup\@@over#2}} — so that it calls the real \over it put aside. A side effect: the old {n \choose k} triggers the same warning by way of \atopwithdelims. It is a warning, not an error, so you still get output, but the right fix is \binom.
Why the fraction came out small: \dfrac and \tfrac
Because \frac changes size by itself according to the style it lands in. Inside $ … $ in running text (text style) it is set small so as not to break the line height; inside \[ … \] (display style) it is set large, with room to breathe. Measure the same \frac{a+b}{c} and the display version is 24.19968pt wide and 13.70952pt high, the text version 16.39322pt and 8.79842pt — about half again as large. To switch that automatic decision off you use amsmath’s \dfrac (always display size) and \tfrac (always text size), which are nothing but aliases for \genfrac: they are defined as \genfrac{}{}{}0 and \genfrac{}{}{}1. Measurement bears it out — a \tfrac inside a display comes out identical to a \frac in text down to the hundred-thousandth of a point.
% preamble: \usepackage{amsmath}
Small in running text: $\frac{a+b}{c}$, forced large: $\dfrac{\partial f}{\partial x}$.
\[
\frac{a+b}{c} \qquad \tfrac{a+b}{c} \qquad \dfrac{1}{1 + \dfrac{1}{x}}
\]Nesting makes the matter more urgent. TeX has only four styles — display, text, script, scriptscript — and the numerator and denominator of a fraction are always set one step down. So stacking \frac shrinks the type display → text → script → scriptscript, and it hits the floor at the fourth level. Measurement agrees: \frac{1}{2} is 7.40001pt wide in display style, 6.38612pt in text style, 5.80283pt in script style — and 5.80283pt in scriptscript style too. The third and fourth levels are the same size; there is nowhere smaller to go. By then, of course, it is long past readable. To keep every level the same size, stack \dfrac instead, or use \cfrac from the next section.
\frac— the default. When you want the natural size, left to the context. No package needed.\dfrac— when a fraction in running text should stay full-size rather than be squashed, or when every level of a nest must be the same size. It pushes the line height open, so a page full of them makes the leading jump.\tfrac— when just one fraction inside a display should stay compact. Good for fractions in coefficients and around scripts.\cfrac— for continued fractions only. The size does not change however many levels deep it goes.
Continued fractions: \cfrac and its [l] / [r] argument
For continued fractions, use amsmath’s \cfrac. Nested \frac shrinks level by level, as the previous section showed; \cfrac sets every level at display size, so the type stays the same however many levels you stack. The definition at line 913 of amsmath.sty tells the whole story: \DeclareRobustCommand{\cfrac}[3][c]{{\displaystyle\frac{\strut\ifx r#1\hfill\fi#2\ifx l#1\hfill\fi}{#3}}\kern-\nulldelimiterspace}. It asserts \displaystyle explicitly, uses a \strut to give every level the same height, and cancels the leftover gap to the right of the bar with a trailing \kern-\nulldelimiterspace.
As the [3][c] in that definition shows, \cfrac takes an optional alignment argument first, defaulting to c (centred). \cfrac[l] sets the numerator flush left, \cfrac[r] flush right. The trick is simple: for r it inserts an \hfill before the numerator, for l an \hfill after it. In a continued fraction the denominator grows longer as you descend, so the bar changes width from level to level; [l] is what lines the numerators up at the left edge.
% preamble: \usepackage{amsmath}
\[
x = 1 + \cfrac{1}{2 + \cfrac{1}{2 + \cfrac{1}{2 + \cdots}}}
\qquad
\cfrac[l]{1}{2 + \cfrac[l]{1}{2 + \cfrac[l]{1}{2}}}
\]Binomial coefficients: \binom is a fraction with a 0pt rule
\binom{n}{k} (amsmath) sets the binomial coefficient “n choose k” as a bar-less vertical stack inside round brackets. No bar is drawn — not because the command is special-cased, but because it is a fraction whose rule thickness is set to 0pt. Line 240 of amsmath.sty reads \DeclareRobustCommand{\binom}{\genfrac()\z@{}}: a \genfrac with ( and ) as its delimiters, \z@ (that is, 0pt) as the rule thickness, and an empty style so it follows the context. If you want the size fixed there are \dbinom (always display) and \tbinom (always text), which are likewise nothing but \genfrac(){0pt}0 and \genfrac(){0pt}1.
\genfrac is the general command that every command so far is built on, and it takes six arguments: \genfrac{left delimiter}{right delimiter}{rule thickness}{style}{numerator}{denominator}. The fourth, the style, is an integer 0–3 selecting \displaystyle, \textstyle, \scriptstyle and \scriptscriptstyle in that order; leave it empty to follow the context. So \genfrac[]{1pt}{0}{a}{b} gives a fraction in square brackets with a thick 1pt rule, always at display size. This is the escape hatch when you need an appearance the standard commands do not offer. The old spelling {n \choose k} draws the amsmath warning shown earlier — replace it with \binom.
% preamble: \usepackage{amsmath}
\[
\binom{n}{k} = \frac{n!}{k!\,(n-k)!}
\qquad \dbinom{n}{k} \qquad \tbinom{n}{k}
\qquad \genfrac[]{1pt}{0}{a}{b}
\]\sqrt and nth roots: the index rides on \root … \of
\sqrt{contents} is a LaTeX kernel command; amsmath is not needed. The radical and the bar running up to its right (the vinculum) stretch automatically to the height and width of the contents. For an nth root you pass the index as an optional argument in square brackets: \sqrt[3]{x+y}. The two are separate implementations. Line 12701 of latex.ltx reads \DeclareRobustCommand\sqrt{\@ifnextchar[\@sqrt\sqrtsign} — if a [ follows, go to \@sqrt, otherwise use the bare glyph \sqrtsign — and line 12702, \def\@sqrt[#1]{\root #1\of}, routes the indexed case through \root … \of. The index is set in \scriptscriptstyle, given a \mkern5mu gap, and raised by 0.6 times the height of the sign. Rudolff’s hook and Descartes’s bar were born apart, and the implementation still shows it.
Once you see the mechanism, the classic complaint makes sense: with a tall radicand, the index ends up somewhere silly. It is raised in proportion to the height of the radical sign, so the taller the contents, the further off to the left of the sign it drifts. amsmath supplies \leftroot{n} and \uproot{n} for adjustment, written immediately before the index, as in \sqrt[\leftroot{2}\uproot{3}\beta]{x}. The unit is mu (math units, 1/18 em). Measured, the box for \sqrt[3]{x} is 8.00272pt high; adding \uproot{10} stretches it to 12.14214pt. \leftroot, by contrast, never changes the width: \r@@t in amsmath.sty inserts \mkern-\leftroot@ mu and \mkern\leftroot@ mu as a cancelling pair, so the advance stays put and only the index slides sideways. Reach for these only when the result really does look wrong; the default placement is usually fine.
% \sqrt is core LaTeX; \leftroot and \uproot need amsmath
\[
\sqrt{x^2 + y^2} \qquad \sqrt[3]{x+y} \qquad \sqrt[n]{a}
\qquad \sqrt[\leftroot{2}\uproot{3}\beta]{\frac{a}{b}}
\]Exponents, and ! Double superscript
Exponents are superscripts, written with the caret ^: x^2 is “x squared”. It is a kernel feature, so no package is needed. The pitfall is an exponent of more than one character, because ^ picks up only the single token that follows it. x^10 is set as “x to the first” followed by a stray 0, and since no error is raised it is easy to miss. Always brace it: x^{10}. Two superscripts on the same base, as in x^2^3, do stop the run with ! Double superscript. — and TeX helpfully offers its own reading, I treat x^1^2 essentially like x^1{}^2. If you really want a double exponent, nest it: x^{2^3}. Putting a subscript and a superscript on the same letter, and the units of math spacing, belong to the separate page “Scripts & spacing”.
% braces decide the scope; x^10 is x-to-the-first followed by 0
\[
x^{10} \qquad x^{2^3} \qquad
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\]Slashed fractions: \nicefrac and \sfrac in running text
If all you want is to say “about 3/4 of an hour” in running text, a small slashed fraction disturbs the line far less than a vertical stack. The old hand is \nicefrac{a}{b} from the nicefrac package, in use since 1998 as part of the units bundle. The newer option is \sfrac{a}{b} from the xfrac package, which belongs to LaTeX3’s l3packages; the copy shipped in TeX Live 2024 is dated 2024-02-13. CTAN’s own description of nicefrac says its facilities are provided, in a cleaner way, by the xfrac package — so for new documents \usepackage{xfrac} with \sfrac is the safe default.
The difference shows up when you measure. In running text (text mode) the box for \sfrac{3}{4} is 9.00314pt wide with a depth of 0.13495pt, while \nicefrac{3}{4} is 11.30565pt wide with a depth of 2.5pt. \sfrac calls on the font’s real numerator and denominator figures, so it is narrower and barely drops below the baseline — which is exactly why it disturbs the leading less. Inside math mode ($ … $), though, the two boxes came out identical at 11.30565pt wide by 2.5pt deep: the advantage of \sfrac is a text-mode advantage. The division of labour is simple — \frac or \dfrac for fractions you want stacked, \sfrac for ones that should stay small in a sentence (\nicefrac if an existing document already uses it).
% \usepackage{nicefrac} (the older one)
It takes about \nicefrac{3}{4} of an hour.
% \usepackage{xfrac} (recommended for new documents)
That is roughly \sfrac{1}{2} of the total, or $\sfrac{1}{2}$ in math mode.| Command | Package needed | What it produces |
|---|---|---|
\frac{a}{b} | none (LaTeX kernel) | fraction with a bar; size follows the context; \over inside |
\dfrac{a}{b} | amsmath | always display size; an alias for \genfrac{}{}{}0 |
\tfrac{a}{b} | amsmath | always text size; an alias for \genfrac{}{}{}1 |
\cfrac{a}{b} | amsmath | continued fraction; every level the same size; [l] / [r] align the numerator |
\binom{n}{k} | amsmath | bar-less binomial in parentheses; \dbinom and \tbinom too |
\genfrac | amsmath | the general form: delimiters, rule thickness and style, in six arguments |
\over | none (TeX primitive) | takes everything to its left in the group as numerator; warns under amsmath |
\sqrt{x} | none (LaTeX kernel) | square root; \sqrt[n]{x} for the nth root; tune the index with \leftroot / \uproot (amsmath) |
\nicefrac{a}{b} | nicefrac | small slashed fraction a/b; from the 1998 units bundle |
\sfrac{a}{b} | xfrac | small slashed fraction; in text mode it uses the font’s own figures and barely disturbs the line |