Math component Problem with matrix
Description
I tested new WP 7.0 and their component Math, and found that it has problem with work with matrixes in LaTeX
Examles -
Multiplication of Two 3×3 Matrices
\begin{aligned}
A &=
\begin{pmatrix}
1 & 2 & -1 \\
0 & 3 & 4 \\
2 & -2 & 1
\end{pmatrix},
&
B &=
\begin{pmatrix}
2 & 0 & 1 \\
-1 & 3 & 2 \\
4 & -2 & 0
\end{pmatrix},
\\[8pt]
AB &=
\begin{pmatrix}
1\cdot2+2\cdot(-1)+(-1)\cdot4 &
1\cdot0+2\cdot3+(-1)\cdot(-2) &
1\cdot1+2\cdot2+(-1)\cdot0
\\
0\cdot2+3\cdot(-1)+4\cdot4 &
0\cdot0+3\cdot3+4\cdot(-2) &
0\cdot1+3\cdot2+4\cdot0
\\
2\cdot2+(-2)\cdot(-1)+1\cdot4 &
2\cdot0+(-2)\cdot3+1\cdot(-2) &
2\cdot1+(-2)\cdot2+1\cdot0
\end{pmatrix}
\\[8pt]
&=
\begin{pmatrix}
-4 & 8 & 5 \\
13 & 1 & 6 \\
10 & -8 & -2
\end{pmatrix}.
\end{aligned}
https://i.ibb.co/rfGGRQKK/Edit-Page-Sample-Page-elementor-test-Word-Pre.png
Finding the inverse matrix using algebraic complements
\begin{aligned}
A &=
\begin{pmatrix}
2 & 1 & 0 \\
-1 & 3 & 2 \\
4 & 0 & 1
\end{pmatrix},
\\[6pt]
\det(A)
&=
\begin{vmatrix}
2 & 1 & 0 \\
-1 & 3 & 2 \\
4 & 0 & 1
\end{vmatrix}
\\
&=
2
\begin{vmatrix}
3 & 2 \\
0 & 1
\end{vmatrix}
-
1
\begin{vmatrix}
-1 & 2 \\
4 & 1
\end{vmatrix}
\\
&=
2(3\cdot1-2\cdot0)
-
\left((-1)\cdot1-2\cdot4\right)
\\
&=6-(-9)=15.
\\[8pt]
\operatorname{adj}(A)
&=
\begin{pmatrix}
3 & -1 & 2 \\
9 & 2 & -4 \\
-12 & 4 & 7
\end{pmatrix},
\\[8pt]
A^{-1}
&=
\frac{1}{\det(A)}\operatorname{adj}(A)
\\
&=
\frac{1}{15}
\begin{pmatrix}
3 & -1 & 2 \\
9 & 2 & -4 \\
-12 & 4 & 7
\end{pmatrix}.
\end{aligned}
https://i.ibb.co/b51JTmSh/Edit-Page-Sample-Page-elementor-test-Word-Pre.png
Singular Value Decomposition (SVD) of a Matrix
\begin{aligned}
A &=
\begin{pmatrix}
3 & 0 \\
4 & 0
\end{pmatrix},
&
A^{\mathsf T}A
&=
\begin{pmatrix}
3 & 4 \\
0 & 0
\end{pmatrix}
\begin{pmatrix}
3 & 0 \\
4 & 0
\end{pmatrix}
=
\begin{pmatrix}
25 & 0 \\
0 & 0
\end{pmatrix}.
\\[10pt]
\det(A^{\mathsf T}A-\lambda I)
&=
\begin{vmatrix}
25-\lambda & 0 \\
0 & -\lambda
\end{vmatrix}
\\
&=\lambda(\lambda-25)=0.
\\[8pt]
\lambda_1&=25,
&
\lambda_2&=0,
\\
\sigma_1&=\sqrt{\lambda_1}=5,
&
\sigma_2&=\sqrt{\lambda_2}=0.
\\[10pt]
\mathbf v_1&=
\begin{pmatrix}
1\\0
\end{pmatrix},
&
\mathbf v_2&=
\begin{pmatrix}
0\\1
\end{pmatrix},
&
V&=
\begin{pmatrix}
1&0\\
0&1
\end{pmatrix}.
\\[10pt]
\mathbf u_1
&=
\frac{A\mathbf v_1}{\sigma_1}
=
\frac{1}{5}
\begin{pmatrix}
3\\4
\end{pmatrix}
=
\begin{pmatrix}
\frac{3}{5}\\[2pt]
\frac{4}{5}
\end{pmatrix},
&
\mathbf u_2
&=
\begin{pmatrix}
-\frac{4}{5}\\[2pt]
\frac{3}{5}
\end{pmatrix}.
\\[12pt]
U&=
\begin{pmatrix}
\frac{3}{5} & -\frac{4}{5} \\
\frac{4}{5} & \frac{3}{5}
\end{pmatrix},
&
\Sigma&=
\begin{pmatrix}
5&0\\
0&0
\end{pmatrix}.
\\[12pt]
A
&=
U\Sigma V^{\mathsf T}
\\
&=
\begin{pmatrix}
\frac{3}{5} & -\frac{4}{5} \\
\frac{4}{5} & \frac{3}{5}
\end{pmatrix}
\begin{pmatrix}
5&0\\
0&0
\end{pmatrix}
\begin{pmatrix}
1&0\\
0&1
\end{pmatrix}
=
\begin{pmatrix}
3&0\\
4&0
\end{pmatrix}.
\end{aligned}
https://i.ibb.co/HTgn3xG2/Edit-Page-Sample-Page-elementor-test-Word-Pre.png
Step-by-step reproduction instructions
- Go to Gutenberd Editor
- Find Block Math
- Add some of example variants,
*I tried testing this using some popular matrix formulas for higher mathematics....
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
- [x] Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- [x] Yes
Please confirm which theme type you used for testing.
- [x] Block
- [ ] Classic
- [ ] Hybrid (e.g. classic with theme.json)
- [ ] Not sure
Which browser are you using? Is the resulting MathML just wrong (indicating an issue with https://temml.org), or is the MathML rendered incorrectly in your browser (indicating a browser issue)?
Which browser are you using? Is the resulting MathML just wrong (indicating an issue with https://temml.org), or is the MathML rendered incorrectly in your browser (indicating a browser issue)?
Google Chrome 150.0 It's incorrectly shows in my browser. For example
\begin{aligned}
A &=
\begin{pmatrix}
3 & 0 \\
4 & 0
\end{pmatrix},
&
A^{\mathsf T}A
&=
\begin{pmatrix}
3 & 4 \\
0 & 0
\end{pmatrix}
\begin{pmatrix}
3 & 0 \\
4 & 0
\end{pmatrix}
=
\begin{pmatrix}
25 & 0 \\
0 & 0
\end{pmatrix}.
\\[10pt]
\det(A^{\mathsf T}A-\lambda I)
&=
\begin{vmatrix}
25-\lambda & 0 \\
0 & -\lambda
\end{vmatrix}
=\lambda(\lambda-25)=0.
\\[8pt]
\lambda_1&=25,
&
\lambda_2&=0,
\\
\sigma_1&=\sqrt{\lambda_1}=5,
&
\sigma_2&=\sqrt{\lambda_2}=0.
\\[10pt]
\mathbf v_1&=
\begin{pmatrix}
1\\0
\end{pmatrix},
&
\mathbf v_2&=
\begin{pmatrix}
0\\1
\end{pmatrix},
&
V&=
\begin{pmatrix}
1&0\\
0&1
\end{pmatrix}.
\\[10pt]
\mathbf u_1
&=
\frac{A\mathbf v_1}{\sigma_1}
=
\frac{1}{5}
\begin{pmatrix}
3\\4
\end{pmatrix}
=
\begin{pmatrix}
\frac{3}{5}\\[2pt]
\frac{4}{5}
\end{pmatrix},
&
\mathbf u_2
&=
\begin{pmatrix}
-\frac{4}{5}\\[2pt]
\frac{3}{5}
\end{pmatrix}.
\\[12pt]
U&=
\begin{pmatrix}
\frac{3}{5} & -\frac{4}{5} \\
\frac{4}{5} & \frac{3}{5}
\end{pmatrix},
&
\Sigma&=
\begin{pmatrix}
5&0\\
0&0
\end{pmatrix}.
\\[12pt]
A
&=
U\Sigma V^{\mathsf T}
=\begin{pmatrix}
\frac{3}{5} & -\frac{4}{5} \\
\frac{4}{5} & \frac{3}{5}
\end{pmatrix}
\begin{pmatrix}
5&0\\
0&0
\end{pmatrix}
\begin{pmatrix}
1&0\\
0&1
\end{pmatrix}
=
\begin{pmatrix}
3&0\\
4&0
\end{pmatrix}.
\end{aligned}
In your program I see this -> https://monosnap.ai/file/jp0cGNjxOikUejAC28X7mdkT5X25Nh But in WP I see this -> https://monosnap.ai/file/0DFLCVVvmDUeIegWOsIWv8yHWy3P9Z
I dug into this a bit. To answer the question above: the MathML being generated is actually correct — it's not a bug in Temml (the library that turns your LaTeX into MathML). You can confirm this by pasting the same LaTeX into Temml's own demo at temml.org it renders fine there.
The problem is that Temml needs some of its own CSS to make matrices and aligned equations line up correctly in different browsers, and the Math block never included that CSS. So the underlying math is right, but without the matching styles, browsers lay it out wrong which matches exactly what you showed: correct in Temml's tool, wrong in WordPress.
I opened a PR with the missing CSS plus some tests.
Please let me know if you spot anything I've overlooked
Thanks @vedant-ere for looking into this! I'd actually already dug into the same root cause independently and can confirm your diagnosis, the MathML Temml generates is correct (matches temml.org's own rendering); the Math block just never shipped Temml's companion CSS for .tml-right/.tml-left cell justification, which is why matrices/aligned blocks misalign.
I've opened a separate PR (https://github.com/WordPress/gutenberg/pull/81019) with a smaller, more targeted fix — just the two missing CSS rules, scoped and guarded to match Temml's own upstream @supports handling (so it doesn't regress Safari, which recognizes but mishandles unguarded -webkit-right/-webkit-left values). Happy to consolidate into a single PR, whichever the maintainers prefer, just flagging so we don't duplicate effort.