OMML/MathML writers: Use upright font for numbers by default#279
Closed
val3344 wants to merge 1 commit intojgm:masterfrom
Closed
OMML/MathML writers: Use upright font for numbers by default#279val3344 wants to merge 1 commit intojgm:masterfrom
val3344 wants to merge 1 commit intojgm:masterfrom
Conversation
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: 1. **ISO 80000-2 Standard** (Quantities and units — Part 2: Mathematics) specifies that numbers should be set in upright (roman) font. 2. **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. 3. **MathML Specification**: The `<mn>` element represents "numeric literal" content and should be rendered with upright font styling unless explicitly overridden with mathvariant attribute. 4. **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) - Numbers now get m:sty="p" attribute by default when no explicit style is set, matching the treatment of uppercase Greek letters (see jgm#255) ### MathML Writer (src/Text/TeXMath/Writers/MathML.hs) - `<mn>` elements now get mathvariant="normal" attribute by default when no explicit style is set, matching the treatment of uppercase Greek letters (see jgm#255) ### Test Data Fix - Fixed test/writer/omml/simplePres.test: Changed ENumber "\946" (β) to 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 - Explicitly styled numbers (e.g., $\mathit{123}$) still render as italic - Variables remain italic - Uppercase Greek letters remain upright (already fixed in jgm#255) - Lowercase Greek letters remain italic - This aligns texmath's output with standard LaTeX/pdfLaTeX behavior ## Related - Closes jgm#255 (uppercase Greek letters fix) - Similar to: Typst issue #4139 "Italic digits do not work in math" ## References - ISO 80000-2:2019: Quantities and units — Part 2: Mathematics https://www.iso.org/standard/64973.html - "Typesetting Mathematics According to the ISO Standard" by Nick Higham https://nhigham.com/2016/01/28/typesetting-mathematics-according-to-the-iso-standard/ - "upright italics (math mode)?" - TeX StackExchange discussion https://tex.stackexchange.com/questions/431740/upright-italics-math-mode - MathML Core specification on `<mn>` element https://w3c.github.io/mathml-core/spec.html - isomath package documentation (ISO 80000-2 compliant typesetting) https://ctan.math.utah.edu/ctan/tex-archive/macros/latex/contrib/isomath/isomath.pdf
2cfe645 to
338b7bc
Compare
Owner
Author
|
My apologies - this was my mistake. I discovered this issue when opening the converted After seeing your response, I checked with MS Office Word on Windows and LibreOffice Writer on Linux, and there are no issues with those. So this is a problem with WPS Linux, not with pandoc or texmath. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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