asciimath / asciimathml

A new home for asciimathml
http://asciimath.org/
MIT License
958 stars 184 forks source link

can't write limit superior or inferior #76

Closed medovina closed 6 years ago

medovina commented 6 years ago

There's apparently no way to write a limit superior or a limit inferior using AsciiMath.

https://en.wikipedia.org/wiki/Limit_superior_and_limit_inferior

To be clear, I'd like to be able to write "lim sup" with "n -> oo" beneath both words, as you can see in examples in the Wikipedia article linked above.

drlippman commented 6 years ago

You can extend the symbols table to add this for your own use. If you're using MathJax to render your AsciiMath, this added in your code before loading MathJax would add a limsup symbol that would render the way you're looking for:

<script type="text/x-mathjax-config">
  MathJax.Hub.Register.StartupHook("AsciiMath Jax Ready",function () {
    AM = MathJax.InputJax.AsciiMath.AM;
    AM.newsymbol({input:"limsup", tag:"mo", output:"lim sup", tex:null, ttype:AM.TOKEN.UNDEROVER});
  });
</script>
medovina commented 6 years ago

Thanks - this is very hepful. I tried this and it works!

Unfortunately in my particular case this is not a solution, since I often use LibreOffice to edit my HTML pages and while LibreOffice will preserve a script tag, it doesn't preserve the type attribute (e.g. type="text/x-mathjax-config") in a script tag. So after I edit the page and save it again, the startup hook will no longer work.

Still, that's a LibreOffice bug, not a MathJax one. So I think you can close this GitHub bug (unless you do plan to add lim sup to AsciiMath itself).

drlippman commented 6 years ago

You could probably put that stuff in a external local configuration file. If you're using the CDN version of MathJax, here's how to do that.

BTW, I just remembered there's another way to get the notation you want without needing to add a new symbol: underset(x rarr 3)("lim sup")

medovina commented 6 years ago

underset works great! With this, I don't need a startup hook at all. Thanks!

It would be helpful to have underset in the documentation at http://asciimath.org - could you add it there?

drlippman commented 6 years ago

There's an open issue on the info site repo to add examples of those, though it looks like it's a couple years old. I'm sure a pull request to add those example would be welcome.

drlippman commented 6 years ago

The documentation has been updated, and it looks like your question was answered, so I'm going to close this issue.

medovina commented 6 years ago

That makes sense. Again, thanks a lot for the documentation improvements!