mathjax / mathjax/MathJax

STIX font alignment differences in SVG text (√ rendering) between MathJax 2.7.4 and 4.1.0

Open
#3,553 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Expected Behavior Upstream
Dominant language
JavaScript
Stars
10.9k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Issue Summary

After upgrading from MathJax 2.7.4 to MathJax 4.1.0, we are observing alignment differences when rendering square root (√) expressions inside SVG elements using STIX fonts.

The same SVG content renders correctly in MathJax 2.7.4, but in MathJax 4.1.0 the radical symbol and overline appear slightly misaligned. This affects visual consistency, especially in manually constructed math expressions within SVG.

Steps to Reproduce:
  1. Create an SVG with elements containing math symbols (e.g., √, superscripts)
  2. Load STIX fonts using @font-face from MathJax 4.1.0
  3. Render the same SVG using MathJax 2.7.4 and MathJax 4.1.0
  4. Compare the alignment of square root expressions

The rendering in MathJax 2.7.4 shows correct alignment of the radical symbol and overline. However, in MathJax 4.1.0:

  • The √ symbol appears slightly shifted
  • The overline length/position differs
  • Spacing and baseline alignment are inconsistent

This appears to be related to differences in STIX (v1) vs STIX2 font metrics. Since the math is being rendered inside raw SVG (not fully typeset by MathJax), the font metric differences are directly visible.

We would expect consistent alignment or guidance on the correct approach when using MathJax fonts in SVG contexts.

Technical details:
  • MathJax Version: 4.1.0 (compared with 2.7.4)
  • Client OS: Windows 10
  • Browser: Chrome (latest)

I am using the following MathJax configuration:

@font-face {
  font-family: 'LearnStix';
  src: url('https://cdn.jsdelivr.net/npm/@mathjax/mathjax-stix2-font@4.1.0/chtml/woff2/mjx-stx-n.woff2') format('woff2');
}
Supporting information:
  • I have attached comparison samples rendered with MathJax 2.7.4 and MathJax 4.1.0.
  • The differences are visible in square root (√) rendering inside SVG , particularly radical alignment and overline positioning.
  • The rendering is consistent in 2.7.4 but shifted in 4.1.0.
  • No errors are reported in the browser console.
  • Full HTML/CSS sample used for reproduction is included in the report.

SVG-Mathjax-2.7.4-font.html
Image

SVG-Mathjax-4.1.0-font.html
Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached SVG-Mathjax-2.7.4-font.html and SVG-Mathjax-4.1.0-font.html samples and reproduce the square-root alignment difference in Chrome. Compare the STIX and STIX2 font metrics used by the raw SVG elements, then determine whether the behavior requires a rendering fix or documented guidance. Done means the cause and expected approach are established, with a regression check or clear explanation of the limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.