Mathjax does not give a latex formula

In my rails application, I am using mathjax (TEX-AMS_HTML) to render latex formulas.

When entering formulas in comments, I use the codec decoding equation editor with TinyMCE.

My current mathjax config ontop (TEX-AMS_HTML):

        "HTML-CSS": {linebreaks: { automatic: true, width: "container" }},
        displayAlign: "left",
        extensions: ["tex2jax.js","MathMenu.js","MathZoom.js"],
        jax: ["input/TeX","output/HTML-CSS"],
        TeX: { extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"] },
        tex2jax: { ignoreClass: "w1", processClass: "active|comments-content" }

      

My problem is that some formulas are not being output, consider the following:

\[ foo\textup{bar} \]

      

This displays foo \ textup . I also noticed some symbols displaying text, for example:

\[ \AE \SS \]

      

This will make \ AE \ SS instead of matching characters.

I have tried switching to SVG by adjusting the inline / display settings and cannot seem to resolve the issue.

Does anyone have an idea why this is happening?

EDIT: Below is an example

<!DOCTYPE HTML>
<html lang="en">
    <head>
        <title>Mathjax</title>
        <script type="text/x-mathjax-config">
            MathJax.Hub.Config({
            "HTML-CSS": {linebreaks: { automatic: true, width: "container" }},
            displayAlign: "left",
            extensions: ["tex2jax.js","MathMenu.js","MathZoom.js"],
            jax: ["input/TeX","output/HTML-CSS"],
            TeX: { extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"] },
            tex2jax: { ignoreClass: "w1", processClass: "active|comments-content" }
            });
        </script>
        <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
    </head>
    <body>
        <div id="wrapper">
            <div id="main">
                <div class="w1">
                    <div class="comments-content">
                        <p>\[foo\textup{bar}\AE\SS\]</p>
                        <p>\[K_{E}=\frac{1}{2}m(\frac{80}{3.6})^{2}\]</p>
                    </div>
                </div>
            </div>
        </div>  
    </body>
</html>

      

which displays as: http://i.imgur.com/bUJXZPX.png

Note that while mathjax is running and displaying the second line correctly, the first latex line is not escaped.

EDIT2 (22/06/2017):
"Note from the future: cdn.mathjax.org is nearing the end of its term, check mathjax.org/cdn-shutting -down for migration tips (and maybe update your answer for future readers ) "- thanks to user Peter Krautzberger This basically means that the cdn used in my sample code will need to be replaced with a localized version of mathjax.

+3


source to share


1 answer


Macros \textup

, \AE

and \SS

are not part of the default MathJax TeX macros and are not defined in your built-in configuration, so the rendering in the image is highlighted in red.

You will see a more specific error if you remove extensions from noundefined

and noerrors

from your config that are also in the merged configTeX-AMS_HTML

, so you need to drop that as well; as you can see from the link, your inline config entails everything TeX-AMS_HTML

. (In production, it is preferable to use a combined config file as they are loaded as one large file.)

For a list of all default MathJax macros, see http://docs.mathjax.org/en/latest/tex.html#supported-latex-commands .

How to define macros in MathJax see https://tex.stackexchange.com/questions/139699/equivalent-of-mathup-for-upright-text-in-math-mode . Hence:



MathJax.Hub.Config({
  TeX: {
    Macros: {
      RR: "{\\bf R}",
      bold: ["{\\bf #1}",1]
    }
  }
});

      

ie, add block Macros

to block TeX

in your config.

(A special case is \textup

which is a LaTeX text mode macro, and MathJax focuses on math mode. Depending on the use case, the math equivalent might be \text{}

, \mathrm{}

or something else, see these TeX.SE questions . Of course you can define \textup

as anything, but you might run into the problem of backing up content to real TeX).

+2


source







All Articles