skip to Main Content

I am battling with a website that looks like this (Minimal Reproducible Example):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MathJax Test</title>
    <script type="text/javascript" defer="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script type="text/javascript">
  window.MathJax = {
    loader: {
      load: ['[tex]/boldsymbol'],
    },
    tex: {
      packages: {
        '[+]': ['boldsymbol'],
      },
      inlineMath: [['$', '$'], ['\(', '\)']],
      processEscapes: true
    },
  };



</script>
<script defer="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/input/tex/extensions/boldsymbol.js" charset="UTF-8"></script>
</head>
<body>
    <p>The price: ( €0.7 )</p>
</body>
</html>

Through a browser, the price appears as "Math input error", because of the € sign.

Obviously, the body should be like this, and I would have no problem:

<p>The price: ( text{€0.7} )</p>

For various irrelevant reasons, I cannot modify the body of the html, however I can modify the head.

Can anyone help me find a solution so that these badly formatted math input appears as intended?

2

Answers


  1. Use this :

    Use this :  inlineMath: [['$', '$'], ['f(', 'f)']],
    
    Instead of : inlineMath: [['$', '$'], ['\(', '\)']],

    Form feed (/f) is commonly used to begin new sections in printed texts, providing a simple yet effective method for controlling page breaks.

    This is the desired output with (/f)

    enter image description here

    Login or Signup to reply.
  2. You can add a TeX input jax pre-filter that inserts the text{} command around the Euro symbol. Here is an example:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MathJax Test</title>
    <script type="text/javascript">
      window.MathJax = {
        startup: {
          ready() {
            MathJax.startup.defaultReady();
            MathJax.startup.document.inputJax[0].preFilters.add(({math}) => {
              math.math = math.math.replace(/u20AC/g, '\text{u20AC}');
            });
          }
        },
        loader: {
          load: ['[tex]/boldsymbol'],
        },
        tex: {
          packages: {
            '[+]': ['boldsymbol'],
          },
          inlineMath: [['$', '$'], ['\(', '\)']],
          processEscapes: true
        }
      };
    </script>
    <script type="text/javascript" defer="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
    </head>
    <body>
        <p>The price: ( €0.7 )</p>
    </body>
    </html>

    This is all done in the document head, so I think that satisfies your conditions.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search