Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MathJax only renders matrix #3331

Open
Andrei-Iosifescu123 opened this issue Feb 11, 2025 · 1 comment
Open

MathJax only renders matrix #3331

Andrei-Iosifescu123 opened this issue Feb 11, 2025 · 1 comment
Labels
Expected Behavior This is how MathJax works

Comments

@Andrei-Iosifescu123
Copy link

Andrei-Iosifescu123 commented Feb 11, 2025

Replace the text below with the details of the issue you are facing.
DO NOT simply erase the form and type a free-form response.

Issue Summary

MathJax only renders matrix, the other LaTeX isn't rendered at all.

Steps to Reproduce:

  1. Create html like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>MathJax TeX Test Page</title>
<script type="text/javascript" id="MathJax-script" async
  src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
</script>
<script>
MathJax = {
  options: {
    enableMenu: false
  }
};
</script>
</head>
<body style="background-color:#00000000;">
<p style="text-align:left;color:#000000;">


Sure! Here are some math equations written in LaTeX syntax without the dollar signs:<br><br>1. A quadratic equation:<br><br>ax^2 + bx + c = 0<br><br><br>2. The Pythagorean theorem:<br><br>a^2 + b^2 = c^2<br><br><br>3. The derivative of a function:<br><br>\frac{d}{dx} f(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}<br><br><br>4. The integral of a function:<br><br>\int_a^b f(x) dx = F(b) - F(a)<br><br><br>5. The quadratic formula:<br><br>x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}<br><br><br>6. Euler's identity:<br><br>e^{i\pi} + 1 = 0<br><br><br>7. The binomial theorem:<br><br>(a + b)^n = \sum_{k=0}^{n} \binom{n}{k} a^{n-k} b^k<br><br><br>8. A matrix representation:<br><br>\begin{bmatrix}<br>a & b \\<br>c & d<br>\end{bmatrix}<br><br><br>9. The chain rule for derivatives:<br><br>\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}<br><br><br>10. The formula for the area of a circle:<br><br>A = \pi r^2<br><br><br>Let me know if you'd like more examples or specific types of equations!</p></body></html>
  1. Open it in Firefox, LaTeX isn't being rendered except for the matrix.

Technical details:

  • MathJax Version: 3.2
  • Client OS: Linux/Android WebView
  • Browser: Firefox 115.5

I am using the following MathJax configuration:

MathJax = {
  options: {
    enableMenu: false
  }
};

and loading MathJax via

<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

Supporting information:

  • Please supply a link to a (live) minimal example page, when possible.
  • If your issue is with the display of the mathematics produced by MathJax, include a screen snapshot that illustrates the problem, when possible.
  • Check your browser console window for any error messages, and include them here.
  • Include the MathJax configuration you are using, and the script tag that loads MathJax itself.

Image

Using the demo at https://www.mathjax.org/#demo properly renders the LaTeX.

@dpvc
Copy link
Member

dpvc commented Feb 11, 2025

In order for MathJax to process TeX notation, you must enclose the mathematics in math delimiters, just as you would in an actual TeX document. The default delimiters for in-line mathematics are \(...\) and for displayed math either $$...$$ or \[...\]. In addition, \begin{...} ... \end{...} also act as delimiters, which is why your matrix is being typeset.

So you need to put one or the other of these delimiters around the math in order for MathJax to be able to identify the math in the page. You probably want to use the display-math delimiters, and remove the <br><br> tags, as MathJax will typeset display math on a separate line with space above and below it automatically.

@dpvc dpvc added the Expected Behavior This is how MathJax works label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Expected Behavior This is how MathJax works
Projects
None yet
Development

No branches or pull requests

2 participants