OMML/MathML writers: Use upright font for numbers by default #279
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes rendering of numbers in OMML and MathML output to use upright
(roman) font style by default, matching the behavior of other LaTeX
engines and typographic standards.
Background and Rationale
According to typographic standards and mathematical typesetting
conventions:
ISO 80000-2 Standard (Quantities and units — Part 2: Mathematics)
specifies that numbers should be set in upright (roman) font.
LaTeX Default Behavior: In math mode, LaTeX renders digits in
upright font by default. The Computer Modern font family, used by
default in LaTeX, has separate italic and upright variants, and numbers
always use the upright variant in math mode.
MathML Specification: The
<mn>element represents "numericliteral" content and should be rendered with upright font styling
unless explicitly overridden with mathvariant attribute.
OMML Specification: Numbers in Office Math ML should use
m:sty="p" (plain/roman) to indicate upright font.
What Changed
OMML Writer (src/Text/TeXMath/Writers/OMML.hs)
is set, matching the treatment of uppercase Greek letters (see \Omega results in MathML in italics #255)
MathML Writer (src/Text/TeXMath/Writers/MathML.hs)
<mn>elements now get mathvariant="normal" attribute by default whenno explicit style is set, matching the treatment of uppercase Greek
letters (see \Omega results in MathML in italics #255)
Test Data Fix
EIdentifier "\946", as Greek letters should be identifiers, not
numbers
Examples
Before:
OMML:
<m:r><m:t>123</m:t></m:r>(rendered as italic in Word)MathML:
<mn>123</mn>(may render as italic depending on context)After:
OMML:
<m:r><m:rPr><m:sty m:val="p" /></m:rPr><m:t>123</m:t></m:r>MathML:
<mn mathvariant="normal">123</mn>Compatibility
italic
Related
References
https://www.iso.org/standard/64973.html
https://nhigham.com/2016/01/28/typesetting-mathematics-according-to-the-iso-standard/
https://tex.stackexchange.com/questions/431740/upright-italics-math-mode
<mn>elementhttps://w3c.github.io/mathml-core/spec.html
https://ctan.math.utah.edu/ctan/tex-archive/macros/latex/contrib/isomath/isomath.pdf