mdBook icon indicating copy to clipboard operation
mdBook copied to clipboard

Default MathJax version 2.7.1 does not render well on Edge

Open TheVeryDarkness opened this issue 2 months ago • 0 comments

Problem

Hello, thanks for providing mdbook with MathJax support! I noticed an issue with rendering formulas in MathJax versions prior to 2.7.5. Alphabetic characters in formulas are not rendered as italic as expected.

Specifically, the character U+03B3 (Greek small letter gamma) is not rendered in italic fonts in MathJax 2.7.1 and 2.7.4, but it works fine in MathJax 2.7.5.

Environment:

  • MacOS M2 Tahoe 26.1 (I just found this issue does not exist on my phone)
  • mdbook 0.5.1
  • Microsoft Edge 142.0.3595.94 arm64 (the latest official version)

Rendered HTML by MathJax for the formula \\( \gamma \\) ($\gamma$) is as follows:

  • MathJax 2.7.1 (Current default):

    <span
      class="mi"
      id="MathJax-Span-22"
      style="font-family: STIXGeneral-Italic; padding-left: 0.305em;"
      >γ<span
        style="display: inline-block; overflow: hidden; height: 1px; width: 0.053em;"
      ></span
    ></span>
    

    γ

  • MathJax 2.7.4 (still not rendering correctly):

    <span
      class="mi"
      id="MathJax-Span-22"
      style="font-family: STIXGeneral-Italic; padding-left: 0.305em;"
      >γ<span
        style="display: inline-block; overflow: hidden; height: 1px; width: 0.053em;"
      ></span
    ></span>
    

    γ

  • MathJax 2.7.5 (fixes the issue):

    <span
      class="mi"
      id="MathJax-Span-22"
      style="font-family: STIXGeneral-Italic; padding-left: 0.305em;"
      >𝛾<span
        style="display: inline-block; overflow: hidden; height: 1px; width: 0.053em;"
      ></span
    ></span>
    

    𝛾

Screenshots of the formula below in different MathJax versions are attached for reference:

\\[
    \\alpha_i + \\beta_i = \\gamma
\\]

\\[
    G_{\\mu\\nu} + \\lambda g_{\\mu\\nu} = \\frac{8 \\pi G}{c^4} T_{\\mu\\nu}
\\]
  • MathJax 2.7.1:

    Image
  • MathJax 2.7.4:

    Image
  • MathJax 2.7.5:

    Image

Proposed Solution

Though it's enough to update the default MathJax version (and users can also modify MathJax version by using the theme hack), I guess it's great to add configurable MathJax support and pick up some previous PRs (for example, https://github.com/rust-lang/mdBook/pull/1918, https://github.com/rust-lang/mdBook/pull/2285 and https://github.com/rust-lang/mdBook/pull/2069). For example, we can have a new configuration item as below:

[output.html.mathjax]
# Specify the MathJax version. However I'm not sure if we should check whether the version exists
version = "*.*.*"

# Or even specify the MathJax URL.
src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-AMS-MML_HTMLorMML"

And if a new PR is appreciated, I'm glad to work on it.

Notes

No response

TheVeryDarkness avatar Nov 24 '25 02:11 TheVeryDarkness