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

A complex formula with two ‘_’ cannot be successfully converted into HTML source code #3067

Closed
Thomas333333 opened this issue Jul 6, 2023 · 2 comments
Labels
Expected Behavior This is how MathJax works

Comments

@Thomas333333
Copy link

Thomas333333 commented Jul 6, 2023

A complex formula with two ‘_’ cannot be successfully converted into HTML source code.

Issue Summary

when I use jekyll to build my blog, I would like to incorporate the functionality to render LaTeX formulas into HTML source code. After adding the corresponding script, it still fails to render this formula:$\hat{y}=\mathrm{argmax}_{y}P_{\theta}({y}|x)$
image

Steps to Reproduce:

  1. Use default jekyll to gender markdown to html source
  2. add mathjax script
  3. render this formula $\hat{y}=\mathrm{argmax}_{y}P_{\theta}({y}|x)$

I guess it is because jekyll will process the part caught by _ first . When it turns to mathjax to play its role, it can't recognize it. I wonder is it a bug for mathjax, because I can't render any formula with two more _

Technical details:

  • MathJax Version: 3.2
  • Client OS: windows11
  • Browser: none

I am using the following MathJax configuration:

and loading MathJax via

<script>
MathJax = {
  tex: {
    inlineMath: [['$', '$']]
  }
};
</script>
<script id="MathJax-script" async
  src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
</script>
@dpvc
Copy link
Member

dpvc commented Jul 6, 2023

You are correct that it is due to Jekyll processing the _ as indicating italics (notice that {y}P are in italics in your image). That means Jekyll has inserted HTML tags into the math to switch to italics, and MathJax doesn't process math that contains HTML tags. This is not a bug in MathJax, it is because Jekyll does not know the difference between mathematics and text, and processes them both the same.

This has been discussed several times before (see #3007, #2757, #830, #329). All of these discuss potential work-arounds.

@dpvc dpvc added the Expected Behavior This is how MathJax works label Jul 6, 2023
@Thomas333333
Copy link
Author

Thank you for your answer, I admire your memory from the bottom of my heart!

@dpvc dpvc closed this as completed Aug 11, 2023
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