# Vertically aligned equation number with underbrace

I would like to vertically aling an equation number for the following MWE:

\documentclass{scrartcl}
\usepackage{amsmath}

\usepackage{mathtools}
\begin{document}
\begin{align}
\begin{aligned}
a &= b \\
&= \underbrace{d+e}_{\substack{\text{Long}\\\text{text}}}
\end{aligned}
\end{align}

$$\begin{multlined} a+b+c+d+e+f+{}\\ g+h+i+\underbrace{i+j}_{\substack{\text{Long}\\\text{text}}} \end{multlined}$$
\end{document}


In both cases underbrace increases the size of the second line and thus, the equation number is not exactly between the two lines. How do I fix this?

This question can be understood as a follow up question of A vertically centered equation number on a multline environment.

-

This works, but requires some manual intervention. The \underbrace can be \smashed to align the equation number as you want. But then, some \vspace needs to be added or the thing following the equation will sit too high.

\documentclass{scrartcl}
\usepackage{amsmath}

\usepackage{mathtools}
\begin{document}
\begin{align}
\begin{aligned}
a &= b \\
&= \smash{\underbrace{d+e}_{\substack{\text{Long}\\\text{text}}}}
\end{aligned}
\end{align}
\vspace*{3ex}
$$\begin{multlined} a+b+c+d+e+f+{}\\ g+h+i+\smash{\underbrace{i+j}_{\substack{\text{Long}\\\text{text}}}} \end{multlined}$$
\vspace*{3ex}

Next line
\end{document}


-
I accept this as a sufficient workaround because it only occurs at limited places in my document. –  Lukas Jan 30 at 13:03
I think a more general answer could include the following: Always align in the middle of the two inner lines for an even number of lines. Always align to the center of the middle line for an odd number of lines. –  Lukas Jan 30 at 13:21
@Lukas Such advice is good. The problem arises because the package algorithms don't/can't always follow that advice without some "help", if abnormalities are introduced in the layout of the multi-line entity. In this case, the \underbrace constitutes such an abnormality. –  Steven B. Segletes Jan 30 at 13:27