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

Spacing after a displayed equation in a narrow screen #3235

Open
cebola2 opened this issue May 24, 2024 · 5 comments
Open

Spacing after a displayed equation in a narrow screen #3235

cebola2 opened this issue May 24, 2024 · 5 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 Test Not Needed v4

Comments

@cebola2
Copy link

cebola2 commented May 24, 2024

Issue Summary

Spacing after a displayed equation in a narrow screen is bigger than on wider screens.

Steps to Reproduce:

  1. Go to https://young.math.tecnico.ulisboa.pt/seminars?id=7274 , in a desktop or tablet, and look at the spacing after the displayed equation.
  2. Go to https://young.math.tecnico.ulisboa.pt/seminars?id=7274 , in some smartphone in portrait orientation, and look at the spacing after the displayed equation.

Technical details:

  • MathJax Version: 4.0beta6
  • Seems to be client and OS independent.

You can look at the MathJax configuration at https://young.math.tecnico.ulisboa.pt/scripts/mathjax4-config.js

Supporting information:

MathJax is loaded locally from https://young.math.tecnico.ulisboa.pt/mathjax4/tex-mml-svg-nofont.js

Screenshot_2024-05-24-12-59-32-43_3aea4af51f236e4932235fdada7d1643

@cebola2
Copy link
Author

cebola2 commented May 24, 2024

It might be related to the first equation in the cases structure being broken. The problem does not occur in similar examples with no line braking.

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team v4 labels May 27, 2024
@dpvc
Copy link
Member

dpvc commented May 27, 2024

This looks to be due to the line breaking that is occurring in the table that is how the cases environment is implemented. It looks like the table is retaining the original width of the cell from before the line-breaking occurred, instead of reducing the column width after the breaks.

I will need to make a pull request to fix that, but haven't worked out the details yet.

@dpvc
Copy link
Member

dpvc commented Jun 6, 2024

OK, I've have the chance to look into this further, and have found the problem, which is what I suspected: the column width is not being reduced in some cases after the line breaking has occurred.

I will submit a PR to fix the problem, but for now, you can incorporate the following into your MathJax configuration:

MathJax = {
  output: {
    displayAlign: "left"
  },
  startup: {
    ready() {
      const {SvgMtable} = MathJax._.output.svg.Wrappers.mtable;
      SvgMtable.prototype.breakColumn = function (i, W) {
        if (this.jax.math.root.attributes.get('overflow') !== 'linebreak' || !this.jax.math.display) return;
        const {D} = this.getTableData();
        let j = 0;
        let w = 0;
        for (const row of this.tableRows) {
          const cell = row.getChild(i);
          if (cell && cell.getBBox().w > W) {
            cell.childNodes[0].breakToWidth(W);
            const bbox = cell.getBBox();
            D[j] = Math.max(D[j], bbox.d);
            if (bbox.w > w) {
              w = bbox.w;
            }
          }
          j++;
        }
        this.cWidths[i] = w;
      }
      MathJax.startup.defaultReady();
    }
  }
};

(The problem was the that last line of the breakColumn() function was being done conditionally, and the condition prevented the column from becoming smaller, as it should.

See if this works for your situation.

@cebola2
Copy link
Author

cebola2 commented Jun 6, 2024

Deployed and it seems to work like a charm. Thanks!

@dpvc
Copy link
Member

dpvc commented Jun 6, 2024

Glad it is working for you. Let us know if you notice any issues that the patch may have caused.

dpvc added a commit to mathjax/MathJax-src that referenced this issue Jun 14, 2024
Allow columns to shrink during line breaking.  (mathjax/MathJax#3235)
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Jun 28, 2024
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 Test Not Needed v4
Projects
None yet
Development

No branches or pull requests

2 participants