Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering error in SVG inline of \frac #3135

Open
kno10 opened this issue Nov 21, 2023 · 3 comments
Open

Rendering error in SVG inline of \frac #3135

kno10 opened this issue Nov 21, 2023 · 3 comments
Labels
Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around Merged Merged into develop branch v4
Milestone

Comments

@kno10
Copy link

kno10 commented Nov 21, 2023

<html>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/tex-svg.js"></script>
\(\frac{1}{123456789}=\)
\[\frac{1}{123456789}=\]
</html>

It appears to work fine with CHTML output. With SVG output, the frac overlaps the equals sign. The display math below is fine.

It is supposed to look as with earlier MathJax: $\frac{1}{123456789}=$

Fiddle: https://jsfiddle.net/pgce2bj5/

@dpvc
Copy link
Member

dpvc commented Nov 21, 2023

Thanks for this report. This seems to be connected to the in-line line breaking, so turning that off is a work-around for now. I'll look into it further and see what I can do.

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Investigate v4 labels Nov 21, 2023
@kno10
Copy link
Author

kno10 commented Nov 22, 2023

Thank you. My current workaround was manual, using \)\(.

MathJax = { output: { linebreaks: { inline: false } } }; makes this issue disappear.

@dpvc
Copy link
Member

dpvc commented Nov 24, 2023

It turns out that MathJax was descending too far into the internal MathML tree when looking or the position of the potential inline breaks, and rather than stopping at the fraction, continued into the fraction and through the break was in the numerator. Because the scaling factor for the node where the break occurs in used to determine the size of the SVG used for the piece between line breaks, it was getting the wrong scaling factor (the scale of the numerator instead of the fractions as a whole) leading to the fraction no getting the proper width.

I have made a PR to resolve the problem. I the meantime, here is a configuration that you can use to patch the incorrect function:

MathJax = {
  startup: {
    ready() {
      const {CommonWrapper} = MathJax._.output.common.Wrapper;
      const getBreakNode = CommonWrapper.prototype.getBreakNode;
      CommonWrapper.prototype.getBreakNode = function (bbox) {
        if (!bbox.start) return [this, null];
        return getBreakNode.call(this, bbox);
      }
      MathJax.startup.defaultReady();
    }
  }
};

@dpvc dpvc added Ready for Review Code Example Contains an illustrative code example, solution, or work-around and removed Investigate labels Nov 24, 2023
@dpvc dpvc added this to the v4.0 milestone Nov 24, 2023
dpvc added a commit to mathjax/MathJax-src that referenced this issue Dec 28, 2023
Don't descend into items that aren't broken when looking for the linebreak node.  (mathjax/MathJax#3135)
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around Merged Merged into develop branch v4
Projects
None yet
Development

No branches or pull requests

2 participants