I would like to have a multi-line equation, where the different terms in each equation of the different lines are aligned centrally, such that I can relate them to each other with underbrace
and overbrace
. The result should look like similar to this:
which I created in LaTeX with
\begin{equation*}
\begin{array}{ccccccc}
\underbrace{\bm u^TPD\bm v}_{\vapprox} &+& \underbrace{\bm u^TD^TP\bm v}_{\vapprox} &=& \underbrace{\bm u^T\bm e_R\bm e_R^T\bm v}_{\veq} &-& \underbrace{\bm u^T\bm e_L\bm e_L^T\bm v}_{\veq}\\
\overbrace{\displaystyle\int_{x_L}^{x_R} uv_x\tr dx} &+& \overbrace{\displaystyle\int_{x_L}^{x_R} u_xv\tr dx} &=& \overbrace{u(x_R)v(x_R)} &-& \overbrace{u(x_L)v(x_L)}
\end{array}
\end{equation*}
I tried two options, which are both not satisfying to me:
- using alignment points
&
, but this does not center the terms, - put everything in a matrix with no delimiter, but this feels a bit hacky and the integrals are too small like they are in inline equations.
Code for first option:
$ underbrace(bold(u)^T P D bold(v), vapprox) &+& underbrace(bold(u)^T D^T P bold(v), vapprox) &=&
underbrace(bold(u)^T bold(e)_R bold(e)_R^T bold(v), veq) &-& underbrace(bold(u)^T bold(e)_L bold(e)_L^T bold(v), veq) \
overbrace(integral_(x_L)^(x_R) u v_x dif x) &+& overbrace(integral_(x_L)^(x_R) u_x v dif x) &=&
overbrace(u(x_R) v(x_R)) &-& overbrace(u(x_L) v(x_L)) $
Code for second option:
#set math.mat(delim: none)
$ mat(
underbrace(bold(u)^T P D bold(v), vapprox), +, underbrace(bold(u)^T D^T P bold(v), vapprox), =, underbrace(bold(u)^T bold(e)_R bold(e)_R^T bold(v), veq), -, underbrace(bold(u)^T bold(e)_L bold(e)_L^T bold(v), veq) ;
overbrace(integral_(x_L)^(x_R) u v_x dif x), +, overbrace(integral_(x_L)^(x_R) u_x v dif x), =, overbrace(u(x_R) v(x_R)), -, overbrace(u(x_L) v(x_L))
) $,
where both of these use
#let vapprox = (rotate(90deg)[$approx$])
#let veq = (rotate(90deg)[$=$])
See also this document: https://typst.app/project/rOQLu8z7tgsvdfAwf8MAst
What would be the best way to achieve this?