You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When converting certain MathML equations to LaTeX using the mathml-to-latex library, the output LaTeX includes unnecessary \left(\right.) and \left.\right) delimiters even when there is no content inside the parentheses. Additionally, spaces between words in mtext elements are handled inconsistently, resulting in the inclusion of \textrm{ } for a simple space.
I looked into it, and while I couldn't get exactly the same output you saw, here’s what I got:
\\left(\\text{Required Value}\\right)_{\\text{other}} \\geq \\frac{21 f t^{3}}{A C H} \\cdot \\left(\\right. \\frac{I_{o}}{1000 B_{\\text{Btu} / \\text{h}}} \\left.\\right)
Notice there’s no \textrm{ } between "Required" and "Value," but I do see the extra \\left( and \\right) showing up unnecessarily. This library is designed to prioritize valid LaTeX syntax, so sometimes it errs on the side of being a bit verbose.
That said, I agree there’s room to clean this up! I made some changes to cut down on unneeded characters. Now, with the latest release, the output for your MathML looks like this:
\\text{Required Value}_{\\text{other}} \\geq \\frac{21 f t^{3}}{A C H} \\cdot \\left(\\right. \\frac{I_{o}}{1000 B_{\\text{Btu} / \\text{h}}} \\left.\\right)
You’ll see that we no longer add parentheses around single child commands. However, the \\left(\\right. and \\left.\\right) are still there. This is expected based on your MathML, which uses separate, childless <mo fence="true">(</mo> and <mo fence="true">)</mo>.
To avoid these in the future, I’d recommend switching to mfenced elements, which better keep opening and closing characters paired.
Description:
When converting certain MathML equations to LaTeX using the mathml-to-latex library, the output LaTeX includes unnecessary \left(\right.) and \left.\right) delimiters even when there is no content inside the parentheses. Additionally, spaces between words in mtext elements are handled inconsistently, resulting in the inclusion of \textrm{ } for a simple space.
Example
Input MathML:
Output LaTeX:
\left(\text{Required}\textrm{ }\text{Value}\right)_{\text{other}} \geq \frac{21 f t^{3}}{A C H} \cdot \left(\right. \frac{I_{o}}{1000 B_{\text{Btu} / \text{h}}} \left.\right)
Expected LaTeX:
\text{Required Value}_{\text{other}} \geq \frac{21 f t^{3}}{\text{ACH}} \cdot \left( \frac{I_{o}}{1000 B_{\text{Btu}/\text{h}}} \right)
The text was updated successfully, but these errors were encountered: