LaTeX Square Root: sqrt, nth Roots and Even Heights

November 11, 2026 · 9 min read

LaTeX Square Root: The \sqrt Command, nth Roots and Sizing

To write a LaTeX square root, type \sqrt{x} in math mode and LaTeX draws a radical sign over everything inside the braces. Add an optional index for other roots, so \sqrt[3]{x} gives a cube root. Both forms are built into LaTeX and render in KaTeX, so they also work in Markdown editors that render math with KaTeX.

Past the basics, square roots in LaTeX get fiddly. This page covers nested roots, long radicands, radicals at uneven heights and the index tweaks KaTeX rejects, and it marks where each command works.

How to Write a Square Root in LaTeX with \sqrt

The LaTeX sqrt command, \sqrt, takes one required argument and needs no package, because it's part of the LaTeX kernel. Put it inside math delimiters, which in Markdown means $...$ for inline math or $$...$$ for a display block. Our guide to Markdown equations explains the delimiters and which platforms render them. Outside math mode, a compiled document stops with a Missing $ inserted error, and a Markdown preview shows the raw command as plain text.

The side of the square is $\sqrt{25} = 5$ meters.

$$
r = \sqrt{x^2 + y^2}
$$

The first line renders as "The side of the square is 25=5\sqrt{25} = 5 meters", with the bar covering both digits. The display block centers r=x2+y2r = \sqrt{x^2 + y^2} on its own line.

Always give sqrt in LaTeX a braced argument. Without braces, \sqrt grabs only the next single token. So \sqrt2 gives 2\sqrt2 correctly, but \sqrt25 gives 25\sqrt25: a root of 2 followed by a loose 5. The same trap turns \sqrt x+1 into x+1\sqrt x+1 instead of x+1\sqrt{x+1}. Subscripts and exponents follow the same one-token rule, as our LaTeX subscript and superscript guide explains.

The LaTeX2e reference for \sqrt adds a sizing detail: the radical grows with its argument. Its left stroke gets steeper as the content gets taller, until it turns vertical for very tall content.

How Do You Write a Cube Root in LaTeX? nth Roots with \sqrt[n]

Put the index in square brackets between the command and the braces. LaTeX sets it small and tucks it into the crook of the radical for you.

$\sqrt[3]{64} = 4$, $\sqrt[4]{16} = 2$, $\sqrt[n]{x}$, $\sqrt[n+1]{x}$

That line renders as 643=4\sqrt[3]{64} = 4, 164=2\sqrt[4]{16} = 2, xn\sqrt[n]{x} and xn+1\sqrt[n+1]{x}. The index can be a number, a letter or a short expression.

Don't write \sqrt[2]{x} for an ordinary square root. It prints a visible 2, giving x2\sqrt[2]{x}, which readers rarely expect. Leave the brackets out and the plain radical already means the square root.

Square Roots of Fractions, Sums and Nested Radicals

Anything can sit under the sign, and the radical stretches to fit. Put a fraction inside the root and the sign grows to cover both lines. Split it into two roots and each sign stays short:

ab=ab\sqrt{\frac{a}{b}} = \frac{\sqrt{a}}{\sqrt{b}}

Sums work the same way. The distance formula and the quadratic formula are two you'll type often:

$$
d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}
$$

$$
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$

Those render as:

d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2} x=−b±b2−4ac2ax = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

For a nested radical, put one \sqrt inside another and close each brace in turn. \sqrt{1+\sqrt{1+\sqrt{x}}} renders as 1+1+x\sqrt{1+\sqrt{1+\sqrt{x}}}, with each outer sign slightly taller than the one it covers. Count your closing braces: a missing one is the usual cause of an error here.

Why Are My Square Roots Different Heights?

LaTeX sizes each radical to its own content. Letters with ascenders or descenders are taller or deeper than letters like aa or xx, so roots placed side by side end up mismatched. Compare these two:

a bx y\sqrt{a}\,\sqrt{b} \qquad \sqrt{x}\,\sqrt{y}

The sign over bb sits higher than the one over aa, and the sign over yy dips lower than the one over xx. In a product or a sum, that looks sloppy.

The fix is \mathstrut, an invisible box with the height of an open parenthesis and no width. Add one to every radical and they all share the same height. The reference entry for \mathstrut defines it as \vphantom{(} and uses a pair of mismatched radicals as its example.

$$
\sqrt{\mathstrut a}\,\sqrt{\mathstrut b} \qquad \sqrt{\mathstrut x}\,\sqrt{\mathstrut y}
$$

That renders as:

(a (b(x (y\sqrt{\mathstrut a}\,\sqrt{\mathstrut b} \qquad \sqrt{\mathstrut x}\,\sqrt{\mathstrut y}

Two alternatives handle specific cases. \vphantom{b} adds the height of a chosen letter without printing it, so \sqrt{\vphantom{b}a}\,\sqrt{b} gives ba b\sqrt{\vphantom{b}a}\,\sqrt{b}. And \smash[b]{y} hides a descender's depth, which keeps one root from dropping lower than its neighbors. The amsmath manual shows it with \sqrt{x} + \sqrt{\smash[b]{y}} + \sqrt{z}, rendered here as x+y+z\sqrt{x} + \sqrt{\smash[b]{y}} + \sqrt{z}.

We prefer \mathstrut over a hand-picked \vphantom. It gives every root the same height without making you guess which letter is tallest. All three commands render in KaTeX and in compiled LaTeX, though \smash[b] needs amsmath in a LaTeX document.

Square roots in LaTeX

Square root: x\sqrt{x} and cube root: x3\sqrt[3]{x}

Nested: 1+1+x\sqrt{1+\sqrt{1+\sqrt{x}}}

Uneven heights:
a b\sqrt{a}\,\sqrt{b}

Fixed with mathstrut:
(a (b\sqrt{\mathstrut a}\,\sqrt{\mathstrut b}

Quadratic formula:
x=−b±b2−4ac2ax = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

32 words286 characters14 lines
Markdown

The Bare Radical Sign: \surd vs \sqrt

Sometimes you want the radical symbol alone, with no bar over anything. That's what \surd is for. It prints a fixed-size √ that never stretches, which suits prose like "press the √\surd key" or a label such as √2\surd 2.

Use \sqrt whenever the sign covers an expression, because only \sqrt draws the bar. Outside math, the character is Unicode U+221A SQUARE ROOT, and you can paste it as plain text. Its neighbors are ∛ (U+221B, cube root) and ∜ (U+221C, fourth root).

Moving the Root Index with \leftroot and \uproot (Not in KaTeX)

With some letters, the default index position looks cramped. The amsmath package adds two commands to nudge it, documented in the amsmath user's guide:

\usepackage{amsmath}
...
$\sqrt[\leftroot{-2}\uproot{2}\beta]{k}$

\uproot raises the index, and a negative value in \leftroot moves it right, closer to the radical. The manual describes the unit as a small amount sized for exactly this kind of nudge.

Here's the limitation. KaTeX doesn't support either command, and its support table lists both as not supported. Our editor's preview renders math with KaTeX, so the root still draws, but \leftroot and \uproot appear as red command names inside the index, next to their stray numbers. MathJax's command list includes both, so MathJax-based renderers accept them, but that won't help you on a KaTeX site.

On a KaTeX page, accept the default placement, which reads fine for numbers. For a letter index, rewrite the root as a power: k^{1/\beta} renders as k1/βk^{1/\beta}. You'll also see closed-root redefinitions on TeX blogs that draw a tick at the end of the bar. They're preamble hacks for compiled LaTeX and can't run in a web renderer.

Long Square Roots That Run Off the Line

A radical can't break across lines, so a long radicand in inline math can push past the edge of the page or screen. You have three ways out, in the order we'd try them.

First, swap the radical for a power of one half. A \sqrt is one unbreakable box, but plain parentheses aren't. KaTeX and LaTeX can wrap inline math after a plus sign inside them:

$(1 + x^2/a^2 + y^2/b^2 + z^2/c^2)^{1/2}$

That renders as (1+x2/a2+y2/b2+z2/c2)1/2(1 + x^2/a^2 + y^2/b^2 + z^2/c^2)^{1/2}, which means exactly the same thing as the root.

Second, name the radicand and define it next to the root. Writing r = \sqrt{Q} and then defining Q on the next line keeps the root short and readable.

Third, as a last resort, put an aligned block inside \sqrt. It renders in KaTeX, but the sign then grows to cover two rows, and most readers find that harder to scan than either option above.

LaTeX Square Root Commands at a Glance: What Renders in Markdown

This table lists the root commands on this page, plus two that people try and KaTeX rejects. "KaTeX" covers our editor and other Markdown tools that use KaTeX. We tested each one in KaTeX 0.16. Our KaTeX vs LaTeX comparison covers what else KaTeX can't render.

CommandWhat it doesKaTeX (Markdown)Compiled LaTeX
\sqrt{x}Square root with a barYesYes
\sqrt[n]{x}nth root with a small indexYesYes
\surdBare radical sign, fixed sizeYesYes
\mathstrutEvens out radical heightsYesYes
\vphantom{...}Adds the height of chosen contentYesYes
\smash[b]{...}Hides a descender's depthYesYes, with amsmath
\leftroot, \uprootNudge the root indexNoYes, with amsmath
\sqrtsign, \strutKernel-level radical and text strutNoYes

If you'd rather build roots by clicking, the LaTeX equation editor renders with KaTeX, has a symbol palette, and copies a Markdown math snippet or exports PNG and SVG. \sqrt, \sqrt[n] and \mathstrut also work in Jupyter notebooks, and the Jupyter Markdown cheat sheet covers the cell syntax.

A LaTeX square root comes down to \sqrt{...} with braces, an optional [n] for other roots, and \mathstrut when neighboring radicals need to match. Everything here except \leftroot, \uproot, \sqrtsign and \strut renders in KaTeX. Paste the examples into the editor and the split view shows each root rendering in the live preview as you type.