Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More description needed for option mathmlSpacing #311

Open
universemaster opened this issue Jun 7, 2022 · 1 comment
Open

More description needed for option mathmlSpacing #311

universemaster opened this issue Jun 7, 2022 · 1 comment

Comments

@universemaster
Copy link

The documentation for options need more information for mathmlSpacing vs TexRules.

I've spent 30 minutes reading through issues and source code but it is still not clear to me precisely what this option does.

It would be great to have an example for each option clearly highlighting the differences.

@dpvc
Copy link
Member

dpvc commented Jun 8, 2022

You are right that there should be more detail about this.

MathML and TeX approach the spacing between items in very different ways. MathML inserts spacing on both sides of <mo> elements (Math Operator elements) based on the Operator Dictionary and the position of the <mo> within the surrounding <mrow> (the <mo> will be in a prefix, infix, or postfix position in the expression). Some renderers also add space in other locations, but that is not required by the specification as it currently stands. For example, Firefox will put a small amount of space between <mi> (Math Identifier) elements when the mathvariant attribute is different between the two <mi>. This means that <mi>sin</mi><mi>x</mi> will have a small space between "sin" and "x", since the multi-character <mi>sin</mi> has the normal variant by default, while the single-character <mi>x</mi> has the italic variant.

TeX, on the other hand, determines spacing based on the class of adjacent items in the expression (not just at operators). TeX assigns each item a TeX class (OP = large operator, BIN = binary operator, REL = relation, OPEN = open delimiter, etc.) and specifies a spacing too use between each possible pairing of adjacent classes (see the TeXBook Chapter 18 (p. 170)). So TeX can have spacing in palces that MathML doesn't, and the spacing does not always agree between the two.

For example, TeX does not put spacing between two adjacent relations; e.g., x == y in TeX will have no extra space between the two equal signs (other than what is part of the glyph in the font itself). But in MathML, both equal signs are in infix position, and so get an equal amount of space on both sides, meaning there will be twice that extra space between the two equals.

MJX-1 vs. MML-1

TeX does some rewriting of classes to make some situations work better. For example, in x + -y to make the minus sign act as negation rather than a binary operator, whereas an extra <mrow> is needed for this case in MathML (and the TeX input jax doesn't add one).

MJX-2 vs. MML-2

Other places involve the spacing between two things neither of which is an <mo>, though the conditions where these include spacing is rare. One is the spacing for \sin x, where both are <mi> nodes:

MJX-3 vs. MML-3

Firefox handles that by putting space between <mi> that have different variants, as discussed above, though MathJax doesn't do that. That approach introduces extra space in places where TeX would not, for example, in a\mathbf{i}.

I hope that helps clarify the difference between the two modes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants