0

I am using MathJax to attempt to render equations with .NET & DocFX.

This equation gives Missing or unrecognized delimiter for \right error in the browser.

\(D_{text{mi}} = 1 - \frac{U_{c}}{U_{i}} = C_{t} - 0.05 - \lbrack \left( 16C_{t} - 0.5 \right) I_{\text{amb}}/1000\rbrack\)

However if I run it in https://www.mathjax.org/#demo then it previewscorrectly.

enter image description here

Here is my script:

{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}}

<script type="text/javascript" src="{{_rel}}styles/docfx.vendor.js"></script>
<script type="text/javascript" src="{{_rel}}styles/docfx.js"></script>
<script type="text/javascript" src="{{_rel}}styles/main.js"></script>

<!-- configure MathJax object to define tex macros -->
<!-- Don't forget to escape \, since js also uses \ -->
<script>

MathJax = {
  tex: {
    packages: ['base'],        // extensions to use
    inlineMath: [              // start/end delimiter pairs for in-line math
      ['\\(', '\\)']
    ],
    displayMath: [             // start/end delimiter pairs for display math
      ['$$', '$$'],
      ['\[', '\]'],
      ['\(', '}\)'],
      ['\(','\)'],
      ['\\[', '\\]'],
    ],
  }
};

</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
Hardgraf
  • 2,566
  • 4
  • 44
  • 77

1 Answers1

0

Your displayMath settings are a bit strange. Note that the strings '\(' and '\(' in javascript represent the characters ( and ) (no backslashes), so you have set plain old parentheses (and plain old brackets) to be display math delimiters (while your inlineMath parameters set \( and \) as the inline math delimiters). I suspect that the displayMath delimiters are being found first, and so your expression

\(D_{text{mi}} = 1 - \frac{U_{c}}{U_{i}} = C_{t} - 0.05 - \lbrack \left( 16C_{t} - 0.5 \right) I_{\text{amb}}/1000\rbrack\)

is matching the

( 16C_{t} - 0.5 \right)

as displayed math (with its delimiters), making the math being processed be 16C_{t} - 0.5 \right. In this case, the \right is missing its argument (because you have parentheses set as display-math delimiters).

I'm not sure what you are trying to accomplish with your displayMath settings, but I suspect they are the source of the problem.

Davide Cervone
  • 11,211
  • 1
  • 28
  • 48