Inline LaTeX not recognized by MathJax in Node.JS service

139 views
Skip to first unread message

Edward Porter

unread,
Feb 8, 2024, 9:35:11 AM2/8/24
to MathJax Users
I have create a MathJax node.js service. It works well excepting the fact that my configuration specifying "$","$" and "\\(", ")\\" are not recognized mathjax as indicators of inline equations. They, instead, are output in the resulting MathML equation. Is something wrong with my initialization?

await require("mathjax").init({
        startup: {
            ready() {
                //
                //  Prevent the serialized MathML from including any of MathJax's data attributes
                //
                const {SerializedMmlVisitor} = MathJax._.core.MmlTree.SerializedMmlVisitor;
                SerializedMmlVisitor.prototype.getDataAttributes = function () {return {}}
                //
                //  Do the usual startup ready actions (create document, input/output jax, etc).
                //
                MathJax.startup.defaultReady();
              }
        },
            options: {
                skipHtmlTags: ["script","noscript","style","textarea","pre","code"],
                sre: {
                    speech: 'deep',
                    domain: 'mathspeak',
                    style: 'default',
                    locale: 'en'
                },
                enableEnrichment: true,
                renderActions: action.speechAction,
            },
            loader: {
                load: ['input/tex', 'input/mml', 'output/svg', 'a11y/sre', 'a11y/semantic-enrich'],
                require: require
            },

            tex: {
                inlineMath: [ ['$','$'], ["\\(","\\)"] ],
                displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
                processEscapes: true,
                processEnvironments: true,
                macros: {...}
            }        
    }





Sending something like: 

{
    "format""TeX",
    "speakText"true,
    "mml"true,
    "math""$\\times$"
}

Returns:
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" alttext="dollar sign times dollar sign">
    <mrow>
        <mo>$</mo>
    </mrow>
    <mo>&#xD7;</mo>
    <mrow>
        <mo>$</mo>
    </mrow>
</math>

I would expect the display="block" attribute and the dollar signs to be omitted.

Davide Cervone

unread,
Feb 12, 2024, 7:55:59 AM2/12/24
to mathja...@googlegroups.com
You don't give enough information about how you are actually calling MathJax from your service (the configuration is not enough to tell what you are doing), but it appears that you may be calling MathJax.tex2chtml() or MathJax.tex2svg() to do the conversion.  Note that these take a single mathematical expression (no delimiters needed), so when you pass "$\\times$" to them, the dollars are considered part of the math to be typeset.  You control the mode (inline or display) for that "display" option to tex2chtml() or tex2svg().

Davide


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/21bbb377-2d08-4cc2-bcf3-8a78336ce2e6n%40googlegroups.com.

Edward Porter

unread,
Feb 13, 2024, 4:41:08 PM2/13/24
to MathJax Users
I call the tex2mmlPromise method. If the inline markup does not work, what would be the appropriate option to pass to this method to generate inline mathML?

Davide Cervone

unread,
Feb 16, 2024, 5:19:32 PM2/16/24
to mathja...@googlegroups.com
Use

MathJax.tex2mmlPromise(tex, {display: false});

for inline and

MathJax.tex2mmlPromise(tex, {display: true});

for display math.

Davide


Reply all
Reply to author
Forward
0 new messages