Skip to content

Errors when using \\ (new linebreak from v4) in siunitx extension #3552

@limefrogyank

Description

@limefrogyank

Issue Summary

I don't know if this is a bug in MathJax or my own extension yet, but it only happens when I use the \\ newline macro. I converted my extension to MathJax v4 and got it to build without errors. I have a demo page that uses many different iterations of the siunitx macros and all of them worked except some examples that used the \displaylines macro. An example would be:

\displaylines{
    \sisetup{fill-angle-degrees}
    \ang{-1;;} \\
    \ang{;-2;} \\
    \ang{;;-3} \\
    \sisetup{fill-angle-degrees = false}
}

Generates:

Image

This example can be seen halfway down the page here: https://limefrogyank.github.io/siunitx-pcc/index.html

It looks like the Mml generator tried to add <mtd> table elements inside the "equation" that needed to be generated instead of just on the outside.

When I tried exploring using the new \\ macro and just removed the \displaylines section, I started getting some really weird results. Sometimes, it works just fine. Sometimes, it would stall loading for maybe 30+ seconds. Sometimes, it would process quickly but give odd results where an mml node seemed to have been inserted out of place. For example, $\ang[fill-angle-seconds]{;-2;} \\ \ang[fill-angle-degrees]{;3;} \\$ generates:

Image when it should look more like:
-2' 0"
0° 3' 

Previous example here: https://limefrogyank.github.io/siunitx-pcc/test.html

I've inspected the MmlNode object that is created after macro call and it seems to look fine. My best guess is that something inside the \\ macro is rearranging everything.

Steps to Reproduce:

You can use the demo pages I linked.
https://limefrogyank.github.io/siunitx-pcc/test.html
https://limefrogyank.github.io/siunitx-pcc/index.html

They are using code from the v4upgrade branch, not the main branch, in case you feel like inspecting my code. The relevant angle code is here: https://github.com/limefrogyank/siunitx-pcc/blob/v4upgrade/ts/angMethods.ts

Technical details:

  • MathJax Version: 4.1.1
  • Client OS: Windows
  • Browser: Edge 146.0.3856.109

I am using the following MathJax configuration:

 MathJax = {
        loader: {
            load: ['[custom]/siunitx.js', '[tex]/gensymb', "[tex]/html","[tex]/color",], //gensymb is required for \degree and \ohm
            paths: { custom: './browser/' }
        },
        tex: {
            packages: { '[+]': ['siunitx', 'gensymb', 'html', "color"] },  //gensymb is required for \degree and \ohm
            inlineMath: { '[+]': [['$', '$']] }
            /* global options go here, see IOptions in options.ts for properties */
            // Uncomment example below: 
            // perMode: 'fraction'
        }
    };

and loading MathJax via

<script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@4/tex-svg.js">

Lastly, there are other console errors, but I can't pursue them yet.

Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
Tracking Prevention blocked access to storage for <URL>.
tex-svg.js:1 No version information available for component [custom]/siunitx.js
(anonymous) @ tex-svg.js:1
/favicon.ico:1  Failed to load resource: the server responded with a status of 404 ()
tex-svg.js:1 Speech generation error: Cannot read properties of undefined (reading 'getAttribute')
speechError @ tex-svg.js:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions