# Underbrace under nested square roots

I am trying to put an underbrace underneath a the innermost of multiple square root signs. Unfortunately, I can't get the brace to line up underneath the entire line. Here's the relevant code and a picture of the output:

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{align*}
\lim_{x\to0}f(f(f(x))) &= f\left(f\left(\lim_{x\to0}f(x)\right)\right) \\
&= \sqrt{\sqrt{\underbrace{\sqrt{1+0}}_{\text{Because $f(x)$ is continuous}}}}
\end{align*}


It should be pretty clear what I'm talking about from the picture.

It would also be cool if I could get the two outermost square root signs to be the same, but it's not a huge deal. The underbrace is the main issue here.

Three suggestions:

• Encase the text below the underbrace in a \mathclap directive so that its width doesn't affect the widths of the outermost and middle square-root symbols,

• Use a \smash[b]{...} directive to ensure that the outer surds have the same (zero) depth, and

• Insert a \\ directive at the end of the second line to ensure enough whitespace below the equation. (The \smash directive has "hidden" the underbrace material from TeX's ordinary spacing calculations.)

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\begin{document}
\begin{align*}
\lim_{x\to0}f(f(f(x)))
&= f\Bigl(f\bigl(\,\lim_{x\to0}f(x)\bigr)\Bigr) \\
&= \sqrt{\sqrt{\smash[b]{\underbrace{\sqrt{1+0}}_{%
\mathclap{\text{because $f(x)$ is continuous}}}}}}\\ % <-- note the "\\"
\end{align*}
Some text following this two-line displayed equation.
\end{document}


You can use a combination of \smashing the and \vphantom to ensure a proper vertical spacing and \mathclap to remove the horizontal intrusion of the under-script.

\documentclass{article}

\usepackage{mathtools,lipsum}

\begin{document}

\lipsum*[1]
\begin{align*}
\lim_{x \to 0} f(f(f(x))) &= f\bigl( f\bigl( \lim_{x \to 0} f(x) \bigr)\bigr) \\
&= \sqrt{\sqrt{\underbrace{\sqrt{1+0}}_{\text{Because $f(x)$ is continuous}}}} \\
&= \sqrt{\sqrt{
\vphantom{\sqrt{1}}
\smash{\underbrace{\sqrt{1+0}}_{\mathclap{\text{Because $f(x)$ is continuous}}}}
}}
\vphantom{\underbrace{\sqrt{1}}_{\text{Because $f(x)$ is continuous}}}
\end{align*}
\lipsum[1]

\end{document}


An additional \vphantom at the end ensures the appropriate vertical spacing after the align is maintained if content follows it.