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

HTML-CSS and SVG output: minimal height for mover base [was [TeX input] \quad has no height] #1706

Closed
pkra opened this issue Feb 27, 2017 · 9 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Available v2.7

Comments

@pkra
Copy link
Contributor

pkra commented Feb 27, 2017

It seems real (La)TeX considers \quad to have a height but the TeX input jax only produces an mspace with width.

An example (distilled from a journal article):

\widehat{\quad}: O \to Y

produces

<math display="block">
  <mrow class="MJX-TeXAtom-ORD">
    <mover>
      <mspace width="1em" />
      <mo>&#x005E;<!-- ^ --></mo>
    </mover>
  </mrow>
  <mo>:</mo>
  <mi>O</mi>
  <mo stretchy="false">&#x2192;<!-- → --></mo>
  <mi>Y</mi>
</math>

but the following is closer to rendering in real LaTeX:

<math display="block">
  <mrow class="MJX-TeXAtom-ORD">
    <mover>
      <mspace width="1em" height="0.5em" />
      <mo>&#x005E;<!-- ^ --></mo>
    </mover>
  </mrow>
  <mo>:</mo>
  <mi>O</mi>
  <mo stretchy="false">&#x2192;<!-- → --></mo>
  <mi>Y</mi>
</math>
@dpvc
Copy link
Member

dpvc commented Feb 27, 2017

No, \quad has no height in TeX; it is just horizontal space, like in MathJax. I suspect that the accent code has a minimum height for the base that isn't in MathJax. If you look at \widehat{} in both LaTeX and MathJax, you'll see the difference.

@dpvc
Copy link
Member

dpvc commented Feb 27, 2017

PS, CommonHTML does have the minimum height, but HTML-CSS and SVG don't.

@pkra pkra added the Accepted Issue has been reproduced by MathJax team label Feb 27, 2017
@pkra pkra changed the title [TeX input] \quad has no height HTML-CSS and SVG output: minimal height for mover base [was [TeX input] \quad has no height]] Feb 27, 2017
@pkra
Copy link
Contributor Author

pkra commented Feb 27, 2017

Thanks. I renamed the issue.

@pkra pkra added this to the A future release milestone Feb 27, 2017
@pkra pkra changed the title HTML-CSS and SVG output: minimal height for mover base [was [TeX input] \quad has no height]] HTML-CSS and SVG output: minimal height for mover base [was [TeX input] \quad has no height] Feb 27, 2017
@pkra
Copy link
Contributor Author

pkra commented Mar 10, 2017

@dpvc do you have any suggestion for a workaround? (This issue came up in production.)

@dpvc
Copy link
Member

dpvc commented Mar 10, 2017

@pkra, you could use

\widehat{\vphantom{x}\quad}

if you want a source-level solution. It would also be possible to use a pre-filter to modify the input to replace \widehat{\quad} with \widehat{\vphantom{x}}. Or you could use an input post-filter to scan the produced MathML for an <mover> with an <mspace> as a base, and add the hight to it. Finally, it would be possible to override the TeX input jax's Accent method so that it checks if the base is an <mspace> and adds the height attribute. Something like

MathJax.Hub.Config({
  TeX: {Parse: {prototype: {
    Accent: function (name,accent,stretchy) {
      var c = this.ParseArg(name);
      if (c.isa(MML.mspace) && c.height == null) c.height = "1ex";
      var def = {accent: true}; if (this.stack.env.font) {def.mathvariant = this.stack.env.font}
      var mml = this.mmlToken(MML.mo(MML.entity("#x"+accent)).With(def));
      mml.stretchy = (stretchy ? true : false);
      var mo = (c.isEmbellished() ? c.CoreMO() : c);
      if (mo.isa(MML.mo)) mo.movablelimits = false;
      this.Push(MML.TeXAtom(MML.munderover(c,null,mml).With({accent: true})));
    }
  }}}
});

should do it (but I haven't tested it).

@pkra
Copy link
Contributor Author

pkra commented Mar 11, 2017

Thanks!

@dpvc dpvc self-assigned this Jun 28, 2017
@dpvc dpvc modified the milestones: A future release, MathJax v2.7.2 Jul 6, 2017
dpvc added a commit to dpvc/MathJax that referenced this issue Jul 7, 2017
@dpvc
Copy link
Member

dpvc commented Jul 7, 2017

The issue1706 branch of my fork of MathJax includes a fix.

@dpvc dpvc removed their assignment Jul 7, 2017
dpvc added a commit that referenced this issue Jul 10, 2017
Add minimum height for accents.  #1706.
@dpvc
Copy link
Member

dpvc commented Jul 10, 2017

==> Merged

@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Jul 10, 2017
dpvc added a commit to mathjax/MathJax-test that referenced this issue Jul 14, 2017
@dpvc
Copy link
Member

dpvc commented Jul 14, 2017

==> In testsuite

MathMLToDisplay/Presentation/ScriptsAndLimits/issue1706.html

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 Fixed Test Available v2.7
Projects
None yet
Development

No branches or pull requests

2 participants