# messy underbrace

I have the following code:

        $$\frac{\partial S}{\partial \epsilon^M} = \underbrace{ \frac{1}{2S} }_{\text{square root }} \cdot \frac{1}{N} \cdot \underbrace{ 2\sum_{i=1}^{N} \left[ \left( \log(\epsilon^M_i)-\log(\epsilon^S_i) \right) }_{\text{power}} \cdot \underbrace{ \frac{1}{\epsilon^M_i} }_{\text{logarithm}} \right]$$


That returns the following output:

It seems to me that \underbrace has some conflict with left[-right] type of commands.

How can I fix the code?

• What did you expect? I see no conflict (just a very confusing formula). May 25, 2016 at 12:24
• Do you want all your underbraces on the same level? Use \vphantom to make them all the same vertical size. May 25, 2016 at 12:26
• @egreg the right] bracket is missing -.-' May 25, 2016 at 12:32
• @A_C You certainly get at least an error from this code; the final \right] is completely misplaced. May 25, 2016 at 12:34
• Matching \left and \right must be at the same level of grouping. You can't have \left[ in the argument to \underbrace and the matching \right] outside it. Use \biggl[ instead of \left[ and \biggr] instead of \right]. Remove the inner \left and \right that serve no purpose. May 25, 2016 at 12:43

Matching \left and \right must be at the same level of grouping. You can't have \left[ in the argument to \underbrace and the matching \right] outside it. Use \biggl[ instead of \left[ and \biggr] instead of \right]. Remove the inner \left and \right that serve no purpose.

According to your input you seem to want something like this:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$$\newcommand{\eqstrut}{\vphantom{2\sum_{i=1}^{N}}} \frac{\partial S}{\partial \epsilon^M} = {\underbrace{\eqstrut \frac{1}{2S} } _{\substack{\text{square} \\ \text{root}}}} \cdot \frac{1}{N} \cdot {\underbrace{ 2\sum_{i=1}^{N} \biggl[ ( \log(\epsilon^M_i)-\log(\epsilon^S_i) ) } _{\text{power}}} \cdot {\underbrace{\eqstrut \frac{1}{\epsilon^M_i} }_{\text{logarithm}}} \!\biggr]$$

\end{document}


I don't think this markup has a sensible meaning, though.