ronkok / Temml

TeX-to-MathML conversion library in JavaScript
https://temml.org/
MIT License
162 stars 12 forks source link

\mathord #53

Closed hbghlyj closed 10 months ago

hbghlyj commented 10 months ago

Example

\begin{gather}
\nabla\varphi\\
\mathord\nabla\varphi
\end{gather}
In Temml \mathord\nabla is italic In LaTeX \mathord\nabla is normal
1

In LaTeX, the \mathord\nabla command is expected to produce a normal (non-italic) nabla symbol. However, in Temml, this symbol is being placed inside a <mi> element, which results in it being rendered in an italicized form.

I suggest place characters that are typically normal in a <mi> element with the attribute mathvariant="normal". This would ensure that the nabla symbol appears in its normal (non-italic) form, consistent with LaTeX conventions.

hbghlyj commented 10 months ago

Example

\mathord\Delta

It appears that the Δ symbol is enclosed within an additional <mi> element,

<mi><mi mathvariant="normal">Δ</mi></mi>

but <mi> is not allowed as child of element <mi> in MathML image

ronkok commented 10 months ago

In the next day or two, I will publish an update that fixes this specific problem. However, I cannot completely fix the larger issue of invalid MathML inside a <mi> element.

In LaTeX, it is possible to wrap a \mathord around an expression. Example: \mathord{\frac a b}. That doesn't make much sense, but it is possible. I can think of no way to express such a thing in MathML but to wrap the expression in an <mi> element. The MathML spec says that is invalid, but I cannot think of any alternative.

Anytime \mathord is wrapped around a single character, Temml will emit an <mi> containing just that character. That is valid MathML. But for larger expressions, I think the invalid MathML is here to stay.

ronkok commented 10 months ago

This instance of the invalid <mi> problem is fixed by release v0.10.22.