# Wrapping text with mathclap

How can I wrap the text from \mathclap so that the text doesn't spill over like the picture?

\usepackage{mathtools}
\makeatletter% From https://tex.stackexchange.com/a/419690/156344
\def\smalloverbrace#1{\mathop{\vbox{\m@th\ialign{##\crcr\noalign{\kern3\p@}%
\tiny\downbracefill\crcr\noalign{\kern3\p@\nointerlineskip}%
$\hfil\displaystyle{#1}\hfil$\crcr}}}\limits}
\makeatother
\begin{document}
$\mu = \int_{-\infty}^{\infty} x f(x)dx = \frac{\int_{-\infty}^{\infty} x f(x)dx}{\int_{-\infty}^{\infty} x f(x)dx} = \underbrace{\bar{x}}_{\mathclap{\text{x-coordinate of centroid of region \mathcal{R} under the graph}}}$
\end{document}


• If it's the vertical alignment you are concerned about, you could add some height by including a \vphantom{$\bigg|$} in the limit text. (Adjust the "bigness" as necessary.) – barbara beeton Apr 20 at 22:45

see, if the following simplified solution is close to what you after:

\documentclass{article}
\usepackage{mathtools}

\begin{document}
$\mu = \int_{-\infty}^{\infty} x f(x)dx = \frac{\int_{-\infty}^{\infty} x f(x)dx}{\int_{-\infty}^{\infty} x f(x)dx} = \underbrace{\bar{x}\strut}_{\mathclap{\begin{smallmatrix} x-coordinate of\\ centroid of region\\ \mathcal{R}  under the graph \end{smallmatrix}{}}}$
\end{document}


it gives:

• What is the strut for? – Evan Kim Apr 22 at 22:38
• @EvanKim, with it is pushed brace under \bar{x} a bit lower (on the position if you instead x have y). you can observe difference, if you delete it. – Zarko Apr 22 at 22:41

A solution with stackengine:

\documentclass{article}

\usepackage{mathtools}
\usepackage[usestackEOL]{stackengine}
\makeatletter% From https://tex.stackexchange.com/a/419690/156344
\def\smalloverbrace#1{\mathop{\vbox{\m@th\ialign{##\crcr\noalign{\kern3\p@}%
\tiny\downbracefill\crcr\noalign{\kern3\p@\nointerlineskip}%
$\hfil\displaystyle{#1}\hfil$\crcr}}}\limits}
\makeatother
\begin{document}

$\mu = \int_{-\infty}^{\infty} x f(x)dx = \frac{\int_{-\infty}^{\infty} x f(x)dx}{\int_{-\infty}^{\infty} x f(x)dx} = \underbrace{\bar{x}}_{\strut\clap{\scriptsize\Shortunderstack{ x-coordinate of centroid of \\ region \mathcal{R} under the graph}}}$

\end{document}