Improve article 2111.09832
Exact location of issue
Appendix 4, Table A2.
https://ar5iv.labs.arxiv.org/html/2111.09832#A4.T2
Problem details
The numbers on the diagonal are meant to be italicized. They have mathvariant="italic" set, but Firefox does not act on that information.
Browser
- Firefox.
- Also a problem in the experimental MathML Core support in Chrome.
- MathJax renders this correctly italicized in mainline Chrome.
Screenshot
Intended behavior from the PDF:

rendering in Firefox 103.0.2 (64-bit):

Judging by the text in MathML Core: https://www.w3.org/TR/mathml-core/#the-mathvariant-attribute
"Authors whose only target is MathML Core are encouraged to use CSS for styling."
I of course tried:
mn[mathvariant="italic"] {
font-style: italic !important;
}
but that does not seem to activate in Firefox. The selector is successful (e.g. I can override font-size), but it looks like the font-style isn't used.
And even more strangely, if I select for the simple "any number" selection, it does activate in Firefox:
mn {
font-style: italic !important;
}
Probably should file a Firefox report on this... Does it sound in any way familiar @brucemiller ?
This may also be an issue that @fred-wang is familiar with. If you have some time to spare Fred, any comments are much appreciated!
Firstly, that's a misquote: the recommendation to use CSS for styling is in the section on mathcolor and mathbackground which are considered to be styling choices. OTOH, mathvariant is generally taken to imply a semantic distinction, not (normally) "styling", and so the spec is not recommending to use CSS for that. And in fact, mathvariant is essentially an instruction to the browser to convert the content to the appropriate Unicode.
Secondly, just like the browser, LaTeXML would normally have converted the characters in question to the appropriate Unicode codepoints, as suggested above, and dropped the mathvariant; it does that for bold letters, bold sans-serif digits, italic greek, etc. However, the Unicode committees have taken the economic approach of only allocating slots with known, provable, testable use-cases, rather than being motivated by vague aesthetics like symmetry or completeness. Since there were no known uses of italic numerals semantically distinct from upright ones, they declined to add those to the math alphanumeric block. So they are left as plain ASCII by LaTeXML; similarly the browser can't convert them either. They're both basically following the specs as best they can.
Now, whether there should still be a way using CSS to apply "styling" to those digits, to get a different font style, I'll leave to @fred-wang.
Fascinating history.
It inspired me to find another use of MathML that Firefox successfully renders as the italic number the author originally intended:
<mtext><em>55.4</em><mtext>
<em> isn't allowed in <mn>, so this particular workaround needs an extra sprinkling of markup abuse.
But indeed, curious to hear what Fred may have to say, also w.r.t having the font-style property available for use on any MathML element.
Oh, this was doubly inspiring - what I had failed to realize with my experiment using class is that the element still had the mathvariant attribute, and that was why Firefox wasn't applying the CSS rule.
But if the mathvariant attribute is completely removed and replaced with a class, as in:
<mn class="italic">55.4</mn>
mn.italic {
font-style: italic;
}
everything works as intended and the number is made italic.
So likely this is the most "MathML Core"-friendly approach to consider.
Yes, so basically regarding MathML Core:
- If it's just about semantics, use the italic character from Unicode. If there are no Unicode code points then
mathvariant="italic"won't do anything anyway per MathML Core. - If it's just about styling, use
font-style: italic. - In theory, it is possible to use
mathvariant="italic"(or equivalently the italic character from Unicode) andfont-style: italic. This would render the italic character with italic style.
The quote from MathML Core says to use the Unicode characters:
mathvariant values other than normal are implemented for compatibility with full MathML and legacy editors that can't access characters in Plane 1 of Unicode. Authors are encouraged to use the corresponding Unicode characters. The normal value is still important to cancel automatic italic of the
element.
Regarding Firefox, it used to do that (not sure these are still present, hopefully they can be removed):
- A hack to make mathvariant attribute cancel any CSS font-style/font-weight, in order to implement the MathML rule that it overrides the deprecated (now unshipped) fontstyle/fontweight attributes from MathML1.
- A hack to make mathvariant fallback to CSS font-style/font-weight.
Does it work "as intended" in MathJax? (which often ignores css)
This isn't purely MathML Core specific; Here's what MathML 3 says: "In principle, any mathvariant value may be used with any character data to define a specific symbolic token. In practice, only certain combinations of character data and mathvariant values will be visually distinguished by a given renderer. " MathML4 is similar. But Core essentially says that if it isn't in Unicode, it isn't even going to try.
Thanks for writing in @fred-wang - that was a very helpful summary for me!
@brucemiller good point about mathjax possibly not applying the MathML CSS correctly. I did a double-take and can report for Mathjax 3.2:
- the element+class rule
mn.italicseems to not match using their CHTML output - the class-only rule
.italicdoes match - there is also the mathjax-specific element+class rule, which also matches:
mjx-mn.italic, as well as the (redundant?) dual-class rule:.mjx-n.italic
Thus, one possible CSS-based implementation for italicized numbers can be the following minimal HTML, which renders natively in Firefox and Chrome+experimental MathML Core, but also works with Chrome+MathJax:
<html>
<head>
<style>
/* specific:
mn.italic, .mjx-n.italic {
class-only: */
.italic {
font-style: italic;
}
</style>
<script>
var canMathML = typeof (MathMLElement) == "function";
if (!canMathML) {
var el = document.createElement("script");
el.src = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js";
document.querySelector("head").appendChild(el);
}
</script>
</head>
<body>
<math>
<mn class="italic">55.4</mn>
</math>
</div>
</body>
</html>
A hack to make mathvariant attribute cancel any CSS font-style/font-weight, in order to implement the MathML rule that it overrides the deprecated (now unshipped) fontstyle/fontweight attributes from MathML1.
I opened https://bugzilla.mozilla.org/show_bug.cgi?id=1788645 for that one
Now resolved in the latest ar5iv update, using latexml v0.8.8.
Thanks all!