[Tex/LaTex] Typesetting 144…4 with “n times” under the 4’s is easy, but what about \sqrt{144…4}

math-mode

Inspired by this question on the math StackExchange, suppose you want to typeset the square root of the number 144…4, that is, 1 followed by n 4's. If you write $\sqrt{1\underbrace{44\ldots4}_{n\ \text{times}}}$, as in the current version of the question, you get a huge radical sign that reaches down to match the "n times" text below the number. Is there an elegant way to typeset this so that the radical sign looks like it would with $\sqrt{144\ldots4}$, but also keeping the underset text in the right place?

Best Answer

I'd recommend the following:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\sqrt{\smash[b]{1\! \underbrace{44\cdots4\,}_\text{$n$ times}}}$
\end{document}

enter image description here

Note that it's syntactically cleaner to place $n$ times inside a \text macro. The \smash[b] command "hides" the stuff below the baseline from TeX, inducing it not to make the lower end of square-root symbol plunge down to far. The \! instruction removes the unnecessary whitespace otherwise inserted by the left-hand end of the underbrace, while \, serves to avoid a clash between the right-hand end of the underbrace and the final 4. Finally, and I realize that some will disagree with me, I think it's better to use \cdots than \ldots in this case.

Addendum: This MWE was meant to produce an image of a single formula in which the "root" of the square-root symbol doesn't plunge down unnecessarily far. If this formula were part of some longer running text, a problem would immediately arise: the following line of text and math -- and, depending on the depth of the underbrace contents, even the line after that -- will run smack over the underbrace material. As @egreg notes in his comment and as @Werner shows in his answer, to keep this from happening the formula should be augmented to contain a \vphantom outside the square-root that has the exact same depth as the formula would have if \smash weren't being used. This may be done, e.g., as follows:

$\vphantom{\underbrace{4}_{n}} \sqrt{\smash[b]{1\! \underbrace{44\cdots4\,}_\text{$n$ times}}}$