javascripthtmlmathjaxasciimath

How to display with MathJax using AsciiMath?


I'm using MathJax to display math formulas in my website. And now, I want to use AsciiMath too. The problem is, when I'm using AsciiMath delimiters `...` instead of MathJax delimiters $...$ it doesn't work.

This is my JS code (works on r.e. with MathJax delimiters):

<script type="text/x-mathjax-config">
 MathJax.Hub.Config({
  tex2jax: {
   inlineMath: [["$","$"],["\\(","\\)"]],
   displayMath: [['$$','$$'], ["\\[","\\]"]]
  },
  asciimath2jax: {
   delimiters: [['\\$','\\$'], ['`','`']]
  }
 });
</script>

So, if I write in my HTML <p>$x^2$</p> it displays: Click to view img.

But, if I write <p>`x^2`</p> the display is: Click to view img.

Also, I'm using this CDN in the bottom of my HTML code:

<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full"></script>

NOTE that if I put it in the top of my HTML code, doesn't work either.


Solution

  • You are loading a configuration file that only includes the TeX input processor, not the AsciiMath one. The only combined configuration files that load both TeX and AsciiMath also load the MathML input processor, so if you are OK With that, then you could use

    <script src="http://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-MML-AM_CHTML-full"></script>
    

    (I've changed your call from the decommissioned MathJax CDN to an active one.)

    If you only want TeX and AsciiMath, then you have to load one fo them using the MathJax.Hub.Config() call, as in

    <script type="text/x-mathjax-config">
     MathJax.Hub.Config({
      jax: ['input/AsciiMath'],
      extensions: ['asciimath2jax.js'],
      tex2jax: {
       inlineMath: [["$","$"],["\\(","\\)"]],
       displayMath: [['$$','$$'], ["\\[","\\]"]]
      },
      asciimath2jax: {
       delimiters: [['\\$','\\$'], ['`','`']]
      }
     });
    </script>
    <script src="http://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS_CHTML-full"></script>