5

I am wondering if there is a better way to point to the median using an \uparrow (or maybe another arrow/method) with text underneath/accompanying it. I had to put this construct in a table to get things to lineup.

\begin{tabular}{c c c}
    $\underbrace{2\quad 9\quad 10\quad 12}_\text{4 elements}$& $\underbrace{19\quad 22}$&$\underbrace{37\quad 39\quad 46\quad 50}_\text{4 elements}$\\
    &   $\Big\uparrow$ &\\
    &&\\
    &$\text{Median}=\frac{19+22}{2}=20.5$&\\
\end{tabular}

Here is the output of the above code snippet:

enter image description here

Thank you for your time.

6

Use \substack and \mathclap to pretend the large subscript has no width.

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\[
\underbrace{2\quad 9\quad 10\quad 12}_{\text{$4$ elements}}
\quad
\underbrace{19\quad 22}_{
  \substack{
    \big\uparrow\\[3pt]
    \mathclap{\text{Median}=\frac{19+22}{2}=20.5}
  }
}
\quad
\underbrace{37\quad 39\quad 46\quad 50}_{\text{$4$ elements}}
\]

\end{document}

enter image description here

Note that \operatorname is no substitute for \mathrm or \text.

1
  • Thank you very much! – Jimmy Touma May 27 '20 at 0:36
3

Maybe just placing an array below the underbrace.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
Compute the median according to the above algorithm
\[
\underbrace{2\quad 9\quad 10\quad 12}_{4\text{ elements}}
\underbrace{19\quad 22}_{\begin{array}{c}
    \Big\uparrow \\[6pt] \operatorname{Median} = \frac{19+22}{2} = 20.5
\end{array}}
\underbrace{37\quad 39\quad 46\quad 50}_{4\text{ elements}}
\]
\end{document}

1
  • Thank you Vincent. You're solution is also neat and I'll use it as well. – Jimmy Touma May 27 '20 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.