Intereting Posts

Nested TikZ nodes
decoration nodes not being placed on the circle they are intended to be on
Create a custom title
Extra inter-line space becomes visible then loading package listings inside amsbook
How to access toc entries with titletoc
Conflict between TikZ with decorations.text library, caption and booktabs packages and progressbar theme
Drawing Multidimensional Array Using Tikz
Copyright metadata into Adobe Reader using pdflatex
LaTeX Error: File subfigure.sty not found
Citing author inline and year in footnote using biblatex
How to draw a circular, inclined road in 3D?
Long text in math equation in latex
Remove tick marks on only one axis in pgfplots
Autocomplete current environment
Is there a good reason for lstlistings code to look so ugly by default?

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?

- automatic size adjustment for nested parentheses
- What is the optimal LaTeX WYSIWYG editor/platform (quality/price) for Windows 8?
- A way to mark things in math mode
- Superscripts appear in various weird places in fractions
- math equation with underline has different heights
- How to make a global setting to box every displayed and inline math?

- Text over/under implies arrow?
- How to write Stirling numbers of the second kind?
- Why does Vim highlighting treat _a differently than _b in math mode?
- double perpendicular symbol (for independence)
- Different ways to enter mathmode - pros and cons
- piecewise function
- MinionPro: math accents on swash capitals
- How to prevent superscripts from moving under \sqrt?

I’d recommend the following:

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

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}}}$
```

```
\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\[
\sqrt{144\ldots4\smash{\llap{$\underbrace{\phantom{44\ldots4}}_{\text{$n$ times}}$}}}
\vphantom{1\underbrace{44\ldots4}_{\text{$n$ times}}}
\]
\end{document}
```

The “entire” number is typeset, followed by a `l`

eft over`lap`

that is `\smash`

ed. The additional (almost duplicate) `\vphantom`

is to ensure that the vertical height of the expression matches that of what is visible, otherwise the underbrace might stretch into text below it.

`amsmath`

provides `\text`

.

The standard overkill TikZ solution using the infamous `\tikzmark`

works great for situations such as this:

- This does require two runs. First one to determine the locations, and the second to do the drawing.

- This is a tweaked version of the solution used in Using \underbrace with table columns, and Overbrace in amsmath align environment.
- The brace is adapted from adding a large brace next to a body of text

```
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathreplacing}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
% Tweak these as necessary
\newcommand*{\BraceAmplitude}{0.4em}%
\newcommand*{\VerticalOffset}{0.4ex}%
\newcommand*{\HorizontalOffset}{0.0em}%
\newcommand*{\SquareBraceVOffset}{-0.4ex}%
\newcommand*{\InsertUnderBrace}[4][]{%
\begin{tikzpicture}[overlay,remember picture]
\draw [decoration={brace,amplitude=\BraceAmplitude},decorate, thick,draw=blue,text=black,#1]
($(#3)+(\HorizontalOffset,-\VerticalOffset)$) --
($(#2)+(-\HorizontalOffset,-\VerticalOffset)$)
node [below=\VerticalOffset, midway] {#4};
\end{tikzpicture}%
}%
\newcommand*{\InsertUnderSquareBrace}[4][]{%
\begin{tikzpicture}[overlay,remember picture]
\draw [text=black,line width=0.7pt, #1]
($(#3)+(0,\VerticalOffset+\SquareBraceVOffset)$) --
($(#3)+(\HorizontalOffset,-\VerticalOffset+\SquareBraceVOffset)$) --
($(#2)+(-\HorizontalOffset,-\VerticalOffset+\SquareBraceVOffset)$)
node [below, midway] {#4} --
($(#2)+(0,\VerticalOffset+\SquareBraceVOffset)$);
\end{tikzpicture}%
}%
\begin{document}
\[
\sqrt{1\tikzmark{StartBraceA}44\cdots4\tikzmark{EndBraceA}\,}
\quad
\sqrt{1\tikzmark{StartBraceB}44\cdots4\tikzmark{EndBraceB}\,}
\]
\InsertUnderBrace[draw=red,text=blue]{StartBraceA}{EndBraceA}{$n$ times}
\InsertUnderSquareBrace[draw=red,text=blue]{StartBraceB}{EndBraceB}{$n$ times}
\end{document}
```

The command `\raisebox`

has two optional argument: the height and depth of the resulting box. You want your expression with underbrace to have zero depth and the natural height, so this works:

```
$\sqrt{1
\raisebox{0pt}[\height][0pt]{$\underbrace{44\ldots4}_{n\ \text{times}}$}}$
```

The `\smash`

command in the Scott H.’s answer does almost the same.

Would something like this work?

```
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\sqrt{\smash{1\underbrace{44\ldots4}_{n\ \text{times}}}\vphantom{1}}$
\end{document}
```

The answers are great but this time I couldn’t stop myself to write up an answer though there are 4 answers already. The detail I’m kind of obsessed is the underbraces and their fat appearance when the argument is short. Thanks to the `mathtools`

package this issue is solved to a great extent and moreover you can also use less intrusive `\underbracket`

. Here are two examples:

```
\documentclass{article}
\usepackage{amsmath,mathtools}
\begin{document}
\[\sqrt{\smash[b]{1\kern-2pt\underbracket[0.5pt][1pt]{4\cdots 44}_\text{$n$ many}}}\]
\[\sqrt{\smash[b]{1\kern-2pt\underbrace{4\cdots 44}_\text{$n$ many}}}\]
\end{document}
```

Notice the brace arms are smoothly rendered instead of a rather crude concatenation.

- How do I change the font size of the axis tick labels in pgfplots?
- Is there a LaTeX widget for iBooks Author?
- Strategies for corrections in book typeset with TeX
- Split-like environment inside cases environment
- How to create a macro with two or three ;-separated arguments?
- Use a symbol in a formula that's been defined over elsewhere
- Nested node class with pictogram decoration
- a new command of the form ———-{TEX}———-
- Page numbering at top of page
- Titles too wide and not hyphenated correctly
- TikZ: Easy drawing of cuboids
- Additive Roman Numeral 4
- Pascal's triangle in tikz with row headers
- Creating a multi-line colored box in LaTeX
- determine character code in LaTeX3 (equivalent for backtick notation)