mathjax / mathjax/MathJax

\phantom seems to be under-calculating width

Open
#3,592 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Accepted SRE v4
Dominant language
JavaScript
Stars
10.9k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Issue Summary

I've noticed that \phantom{} is producing content that seems to be too narrow.

Steps to Reproduce:
  1. At the demo site, try:
$$(1+2+3)$$

$$(\phantom{1}+\phantom{2}+\phantom{3})$$

I see a few things. Mainly, the space where phantom elements are is too narrow for what is phantomed out. There is also some asymmetry in the example above, where there is more space for the \phantom{1} than for the \phantom{3}. If anything, it should be the other way.

Image

It does not seem to change anything if I wrap the \phantom instances in \mathord{}. In other words, it seems the missing space is due to something more than the spacing that surrounds the binary operators.

Technical details:
  • MathJax Version: 4.1.3 (at the demo site)
  • Client OS: (e.g., Mac OS Tahoe 26.5.2)
  • Browser: (Firefox 152.0.6)
  • I see this with both CHTML and SVG math rendering.

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

Reproduce the reported expressions on the MathJax demo site in both CHTML and SVG output, comparing normal content with \phantom content. Trace the rendering entry point for \phantom and verify that the phantom widths match the hidden expressions and preserve the reported spacing symmetry.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, latex
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.