# What causes the problem when compiling a displayed equation with \overbrace and \underbrace?

$$\left( \begin{array}{c} m+n\\ m \end{array} \right) = \frac{(m+n)!}{m!n!} = \frac{\overbrace{(m+n)(m+n-1)\cdots(n+1)}^\mbox{m factors}}{\underbrace{m(m-1)\cdots 1}_\mbox{m factors}}$$


I am getting an error and cannot figure out the cause.

• Next time, please also post the content of the error. And if you can include the documentclass etc that make this into a MWE, that would be even better. Jul 18 '16 at 3:30
• Since the answers don't tell: ^\mbox{...} and _\mbox{...} are the problems. Better: ^{\mbox{...}}. Even better: ^{\text{...}}. (Also please have a look at Why is $…$ preferable to $$…$$?) Jul 18 '16 at 8:14

I suggest you use  instead  for display math formulas. Like @WillieWong say, with amsmath package You can get a result, perhaps, more appropriate:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$\binom{m+n}{m} = \frac{(m+n)!}{m!\,n!} = \frac{\overbrace{(m+n)(m+n-1)\cdots(n+1)}^{m \text{ factors}}}{\underbrace{m(m-1)\cdots 1}_{m \text{ factors}}}$
\end{document}


• ^{\text{$m$ factors}} is better Jul 18 '16 at 8:22
• I see, can you explain me, why ^{\text{$m$ factors}} is better? Jul 19 '16 at 2:27

This will do:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$$\left( \begin{array}{c} m+n\\ m \end{array} \right) = \frac{(m+n)!}{m!n!} = \frac{\overbrace{(m+n)(m+n-1)\cdots(n+1)}^{\mbox{m factors}}}{\underbrace{m(m-1)\cdots 1}_{\mbox{m factors}}}$$
\end{document}


The ^\mbox{$m$ factors} was changed to ^{\mbox{$m$ factors}} in two cases (one for superscript and another for subscript), which should be grouped using curly braces.

• If one is using amsmath, one might as well use \binom instead of doing it by hand in the left hand side. It may also make sense using \text instead of \mbox. Jul 18 '16 at 3:29
• @WillieWong: I do agree with you regarding the use of \text instead of \mbox. Jul 18 '16 at 4:23