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

Behavior of \llap and \rlap #694

Closed
fgdorais opened this issue Dec 14, 2013 · 3 comments
Closed

Behavior of \llap and \rlap #694

fgdorais opened this issue Dec 14, 2013 · 3 comments
Labels
Expected Behavior This is how MathJax works

Comments

@fgdorais
Copy link

The \llap and \rlap command behave differently than in LaTeX equations. There may be a good reason for that but I haven't found that difference behavior documented anywhere.

The difference is that in MathJax the two arguments are in math mode, whereas in LaTeX the first argument is in text mode and the second is in math mode. The snippet $\rlap{textmode\qquad}{\qquad mathmode}$ illustrates the difference.

@dpvc
Copy link
Member

dpvc commented Dec 14, 2013

Yes, it was intentional, and the reason is that MathJax really doesn't do text-mode material, so it seemed pointless to switch to text mode just to have to switch back via dollar signs.

As a technical note, \llap and \rlap only take one argument, not two, and place that argument into a zero-width box with negative space either at the beginning or end of the argument so that the contents of the box overlaps what came before or after it. In particular, you would do $abc\llap{X}$ not $\llap{X}{abc}$ to get an X placed over the c an abc.

If you want to implement \llap and \rlap so that their argument is in text mode, you could do it by adding

<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
  var MML = MathJax.ElementJax.mml,
      TEX = MathJax.InputJax.TeX;

  TEX.Parse.Augment({
    Lap: function (name) {
      var mml = MML.mpadded.apply(MML,this.InternalMath(this.GetArgument(name))).With({width: 0});
      if (name === "\\llap") {mml.lspace = "-1 width"}
      this.Push(MML.TeXAtom(mml));
    }
  });
});
</script>

somewhere before the script that loads MathJax.js. Note, however, that you can't use macros in text mode, since MathJax doesn't process them. So $\rlap{text\qquad}abcd$ would overlap the string "text\qquad" (with the "\qquad" displayed as those 6 characters) on top of the "abcd".

@fgdorais
Copy link
Author

Thanks Davide!

That makes sense. Could these incompatibilities with TeX be listed somewhere? It can be a real pain to look for this kind of stuff.

@dpvc
Copy link
Member

dpvc commented Dec 14, 2013

That is in the works. Sorry it is not available now. There are not too many such differences. The other big one is that \raise and \lower don't require boxes, so you can use \raise 2pt {x+y} rather than having to use \raise 3pt \hbox{$x+y$} (though the box form is also allowed). MathJax also requires braces in some places that TeX doesn't. For example, \vec \bf x is acceptable in TeX, but needs to be \vec{\bf x} in MathJax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Expected Behavior This is how MathJax works
Projects
None yet
Development

No branches or pull requests

2 participants