2

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}

enter image description here

Evan Kim
  • 430
  • 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 '19 at 22:45

2 Answers2

3

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:

enter image description here

Zarko
  • 296,517
3

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}

enter image description here

Bernard
  • 271,350