# Problems with \smashoperator: Limit controls must follow a math operator

\documentclass[a4paper]{report}

\usepackage{mleftright}
\usepackage{amsmath}
\usepackage{stackengine}
\usepackage{scalerel}
\usepackage{mathtools}
\usepackage{braket}

\newcommand\equalhat{\mathrel{\stackon[1.5pt]{=}{\stretchto{%
\scalerel*[\widthof{=}]{\wedge}{\rule{1ex}{3ex}}}{0.5ex}}}}

\DeclareMathOperator{\Tr}{Tr}

\begin{document}

\begin{align}
\underbrace{\hat{\rho'}_{ss}^{ \mleft( 2 \mright) } \equalhat \hat{\rho'}_{ss}^{ \mleft( 1 \mright) }}_{\smashoperator[b]{of \, equivalent \, form}} & = \Tr^{ \mleft( 2 \mright) } \mleft( \hat{\rho}_{ss} \mright) = \sum_{\bullet \in \{ \uparrow, \downarrow \} } \bra{\bullet}^{ \mleft( 2 \mright) } \mleft( \ket{ss} \bra{ss} \mright) \ket{\bullet}^{ \mleft( 2 \mright) } \nonumber \\
& = \frac{1}{2} ( \bra{\uparrow}^{ \mleft( 2 \mright) } \mleft( \ket{\uparrow \downarrow} \bra{\uparrow \downarrow} - \ket{\uparrow \downarrow} \bra{\downarrow \uparrow} - \ket{\downarrow \uparrow} \bra{\uparrow \downarrow} + \ket{\downarrow \uparrow} \bra{\downarrow \uparrow} \mright) \ket{\uparrow}^{ \mleft( 2 \mright) } \nonumber \\
& \quad \, + \bra{\downarrow}^{ \mleft( 2 \mright) } \mleft( \ket{\uparrow \downarrow} \bra{\uparrow \downarrow} - \ket{\uparrow \downarrow} \bra{\downarrow \uparrow} - \ket{\downarrow \uparrow} \bra{\uparrow \downarrow} + \ket{\downarrow \uparrow} \bra{\downarrow \uparrow} \mright) \ket{\downarrow}^{ \mleft( 2 \mright) } ) \nonumber \\
& = \frac{1}{2} \mleft( \ket{\downarrow}^{ \mleft( 1 \mright) } \bra{\downarrow}^{ \mleft( 1 \mright) } + \ket{\uparrow}^{ \mleft( 1 \mright) } \bra{\uparrow}^{ \mleft( 1 \mright) } \mright) \, .
\end{align}

\end{document}


produces the error: Limit controls must follow a math operator.

What do I have to change? I have the horizontal space that what is under the underbrace takes up to be ignored for other objects (they are right of it).

[The other questions on here with the same error were typos or the suggestion was to not load certain interfering packages. A) which package would that be and B) since this is part of a large document I'm not sure this is a viable option.

EDIT: I now remember that I meant to use \smash[b] and that works. \smashoperator only takes [l] and [r] as arguments as Mico pointed out.

\smashoperator produces a horizontal smashing, so the optional argument can be [l] or [r] (default is [c]). Maybe this code , with some slight improvements (e.g. using medium-sized fraction for the numerical coefficients), produces what you want?

\documentclass[a4paper]{report}

\usepackage{mleftright}
\usepackage{amsmath}
\usepackage{stackengine}
\usepackage{scalerel}
\usepackage{nccmath, mathtools}
\usepackage{braket}

\newcommand\equalhat{\mathrel{\stackon[1.5pt]{=}{\stretchto{%
\scalerel*[\widthof{=}]{ ∧ }{\rule{1ex}{3ex}}}{0.5ex}}}}

\DeclareMathOperator{\Tr}{Tr}

\begin{document}

\begin{align}
\underbrace{\hat{\rho'}_{ss}^{ \mleft( 2 \mright) } \equalhat \hat{\rho'}_{ss}^{ \mleft( 1 \mright) }}_{%\smashoperator[b]{
\clap{\footnotesize of equivalent form}}
& = \Tr^{ \mleft( 2 \mright) } \mleft( \hat{ρ}_{ss} \mright) = \smashoperator{\sum_{\bullet \in \{ \uparrow, \downarrow \} } }\bra{\bullet}^{ \mleft( 2 \mright) } \mleft( \ket{ss} \bra{ss} \mright) \ket{\bullet}^{ \mleft( 2 \mright) } \nonumber \\
& = \smash{\mfrac{1}{2}}\mleft( \bra{\uparrow}^{ \mleft( 2 \mright) } \mleft( \ket{\uparrow \downarrow} \bra{\uparrow \downarrow} - \ket{\uparrow \downarrow} \bra{\downarrow \uparrow} - \ket{\downarrow \uparrow} \bra{\uparrow \downarrow} + \ket{\downarrow \uparrow} \bra{\downarrow \uparrow} \mright) \ket{\uparrow}^{ \mleft( 2 \mright) }\mright. \nonumber \\
& \quad \mleft. + \bra{\downarrow}^{ \mleft( 2 \mright) } \mleft( \ket{\uparrow \downarrow} \bra{\uparrow \downarrow} - \ket{\uparrow \downarrow} \bra{\downarrow \uparrow} - \ket{\downarrow \uparrow} \bra{\uparrow \downarrow} + \ket{\downarrow \uparrow} \bra{\downarrow \uparrow} \mright) \ket{\downarrow}^{ \mleft( 2 \mright) }\mright) \nonumber \\
& = \mfrac{1}{2} \mleft( \ket{\downarrow}^{ \mleft( 1 \mright) } \bra{\downarrow}^{ \mleft( 1 \mright) } + \ket{\uparrow}^{ \mleft( 1 \mright) } \bra{\uparrow}^{ \mleft( 1 \mright) } \mright) \, .
\end{align}

\end{document}


• @Mico: This happens when I close the edit window, and reopen it, and the equation is rather long, I didn't notice it. Thanks for for pointing it! – Bernard Jun 3 '20 at 17:18

\smashoperator is a macro provided by the mathtools package. Its argument must contain an "operator", such as \sum, \prod, or \int and its arguments, e.g., the indices of summation or the lower and upper limits of integration. \smashoperator can take an optional argument -- either [l] or [r] -- to indicate that the "smashing" should be limited on the left or the right.

\underbrace{...}_{\smashoperator[b]{of \, equivalent \, form}}


Not an operator in sight, is there? Moreover, the [b] option cannot go over well either.

What you should be writing is

\underbrace{...}_{\mathclap{\text{of equivalent form}}}


\mathclap is also defined by the mathtools package.

Addendum: Here's a full version of your equation, which applies both \smash[b] and \mathclap to the underbrace term and a \smashoperator directive aimed at the \sum term. I've also gotten rid of all \mleft and \mright wrappers, as they either do nothing (except create code clutter) or fail to produce larger parentheses.

\documentclass[a4paper]{report}
\usepackage{stackengine, % 'amsmath' is loaded by 'mathtools'
scalerel,mathtools,braket}
\newcommand\equalhat{\mathrel{\stackon[1.5pt]{=}{\stretchto{%
\scalerel*[\widthof{=}]{\wedge}{\rule{1ex}{3ex}}}{0.5ex}}}}
\DeclareMathOperator{\Tr}{Tr}

\begin{document}

\begin{align}
\smash[b]{\underbrace{\hat{\rho'}_{ss}^{(2)} \equalhat \hat{\rho'}_{ss}^{(1)}}_{%
\mathclap{\text{of equivalent form}}}}
&= \Tr^{(2)} (\hat{\rho}_{ss}) =
\smashoperator{\sum_{\bullet \in \{ \uparrow,\downarrow \} }} \bra{\bullet}^{(2)}
\bigl( \ket{ss} \bra{ss} \bigr) \ket{\bullet}^{(2)} \nonumber \\
&= \frac{1}{2} \Bigl[ \bra{\uparrow}^{(2)}
\bigl(  \ket{\uparrow\downarrow} \bra{\uparrow\downarrow}
- \ket{\uparrow\downarrow} \bra{\downarrow\uparrow}
- \ket{\downarrow\uparrow} \bra{\uparrow\downarrow}
+ \ket{\downarrow\uparrow} \bra{\downarrow\uparrow}
\bigr) \ket{\uparrow}^{(2)} \nonumber \\