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

[TeX] \overset should prevent movable limits #1929

Closed
pkra opened this issue Feb 13, 2018 · 8 comments
Closed

[TeX] \overset should prevent movable limits #1929

pkra opened this issue Feb 13, 2018 · 8 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Available v2.7

Comments

@pkra
Copy link
Contributor

pkra commented Feb 13, 2018

\overset can create movable limits which does not match real LaTeX behavior.

E.g., \overset {\rightarrow}{\prod } creates <mover> <mo>&#x220F;</mo> <mo stretchy="false">&#x2192;</mo> </mover> which, if inline, will render as a superscript (as expected). Real LaTeX always renders the arrow above the product.

@dpvc
Copy link
Member

dpvc commented Feb 13, 2018

It looks like the issue is line 1467 of the TeX input jax, which I guess should just be

base.movablelimits = false;

and similarly for line 1472 just below that.

@dpvc dpvc added Ready for Development Accepted Issue has been reproduced by MathJax team labels Feb 13, 2018
@dpvc
Copy link
Member

dpvc commented Feb 13, 2018

PS, this was trying to set it only when needed, but it wasn't properly taking the defaults from the operator dictionary into account.

@pkra
Copy link
Contributor Author

pkra commented Feb 28, 2018

I have trouble overloading this via the configuration. I would have thought I could use TeX: { Augment: { Parse: prototype to overload it but that didn't work for me. @dpvc would you have a pointer for patching this on the fly (with mathjax-node in mind)?

@dpvc
Copy link
Member

dpvc commented Feb 28, 2018

Unfortunately, you won't be able to do it through the configuration this way because the replacement routine needs to call MML.overset, where MML is MathJax.ElementJax.mml, but you don't have access to the MathJax variable to do this. Since your replacement function in the configuration object is parsed in the file that calls mathjax-node, all its variables are local to that file, and so trying to use MML or MathJax will result in an undefined variable. The only thing from the mathjax-node namespace the you have access to will be this when your function is called, and that will refer to the MathJax.InputJax.TeX.Parse object. Unfortunately, it doesn't contain any references to MML or MathJax, and I don't see any way to get to one.

So you will have to use a slightly more circuitous method. Now the you have made extensions easier to access, you can set up a MathJax extension that patches the TeX input jax and ask for that to be loaded in your configuration. Since the extension runs inside the mathjax-node jsdom window, it will have access to MathJax from there.

So you can create a patch directory in your project and place a file called overset-underset.js in it containing the following:

var MML = MathJax.ElementJax.mml;

MathJax.Hub.Register.StartupHook("TeX Jax Ready", function () {
  MathJax.InputJax.TeX.Augment({
    Parse: {prototype: {
      Overset: function (name) {
        var top = this.ParseArg(name), base = this.ParseArg(name);
        base.movablelimits = false;
        this.Push(MML.mover(base,top));
      },
      Underset: function (name) {
        var bot = this.ParseArg(name), base = this.ParseArg(name);
        base.movablelimits = false;
        this.Push(MML.munder(base,bot));
      }
    }}
  });
});

MathJax.Ajax.loadComplete('[patch]/overset-underset.js');

and then use

mjAPI.config({
  paths: {'patch': path.join(__dirname,'patch/')},
  extensions: '[patch]/overset-underset.js'
});

in your node project to set up and load the extension.

At least that seems to work for me.

@pkra
Copy link
Contributor Author

pkra commented Feb 28, 2018

Unfortunately, you won't be able to do it through the configuration this way because the replacement routine needs to call MML.overset, where MML is MathJax.ElementJax.mml, but you don't have access to the MathJax variable to do this.

Ah, that explains my failure. Thanks.

So you can create a patch directory in your project

Right. Though the new path option for mathjax-node hasn't entered a release yet. Should I prep one?

@dpvc
Copy link
Member

dpvc commented Mar 1, 2018

Though the new path option for mathjax-node hasn't entered a release yet.

You could use an explicit file:// URL with the full path to the patch file in the extensions property (and leave off the paths), provided you use the same URL in the loadComplete() call in the patch file instead. You might be able to get away with a relative path, but I didn't test that.

Should I prep one?

Not just yet, thanks.

@dpvc dpvc added this to the A future release milestone Mar 18, 2018
@dpvc dpvc modified the milestones: A future release, MathJax v2.7.4 Mar 29, 2018
dpvc added a commit to dpvc/MathJax that referenced this issue Mar 30, 2018
dpvc added a commit that referenced this issue Mar 30, 2018
Always set movablelimits to false in overset and underset.  #1929
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Mar 30, 2018
@dpvc
Copy link
Member

dpvc commented Mar 30, 2018

==> Merged.

@dpvc dpvc closed this as completed Mar 30, 2018
dpvc added a commit to mathjax/MathJax-test that referenced this issue Mar 30, 2018
@dpvc
Copy link
Member

dpvc commented Mar 30, 2018

==> In testsuite
LaTeXToMathML/above-below/issue1929.html

dpvc added a commit to mathjax/MathJax-test that referenced this issue Mar 30, 2018
@dpvc dpvc added Fixed v2.7 and removed Merged Merged into develop branch labels Apr 2, 2018
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