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 conversion doesn't work properly for some formulas. #3007

Closed
duvelix opened this issue Feb 23, 2023 · 2 comments
Closed

Mathjax conversion doesn't work properly for some formulas. #3007

duvelix opened this issue Feb 23, 2023 · 2 comments
Labels
Expected Behavior This is how MathJax works

Comments

@duvelix
Copy link

duvelix commented Feb 23, 2023

Issue Summary

Mathjax conversion doesn't work properly for some formulas.

Steps to Reproduce:

  1. I'm building a github page built using Jekyll. (and Minimal-mistakes theme)
  2. I'm trying to enter formulas using Mathjax, but I'm having a problem with some formulas not being converted.
  3. After checking them one by one, I found that formulas containing curly brackets were not converted properly.

For example,

\mathbf{w} 

prints fine, but like

\mathbf{w}_{N-1} 

don't.

I don't know what's causing the problem, could you tell me how to fix it?

Technical details:

  • MathJax Version: 2.7.5
  • Client OS: Windows 10 21H2 (19044.2604)
  • Browser: Chrome 110.0.5481.178 (64 bit)

I am using the following MathJax configuration:

<script type="text/javascript" async
	src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-MML-AM_CHTML">
</script>

and loading MathJax via

<script type="text/x-mathjax-config">
   MathJax.Hub.Config({
     extensions: ["tex2jax.js"],
     jax: ["input/TeX", "output/HTML-CSS"],
     tex2jax: {
       inlineMath: [ ['$','$'], ["\\(","\\)"] ],
       displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
       processEscapes: true
     },
     "HTML-CSS": { availableFonts: ["TeX"] }
   });
</script>

Additional information (Screenshots and links)

https://joonsuryu.github.io/studies/theory-of-generalization/

1

https://joonsuryu.github.io/studies/bias-variance-tradeoff/

2

@dpvc
Copy link
Member

dpvc commented Feb 23, 2023

It's not the braces that are the problem it is the underscores. Markdown uses underscores to indicate italics (notice how the {1} ~ \mathbf{x} in your screen shot is in italics — this is the math between two underscores), and that means that your page will have <i> tags or some other markup within the mathematics. MathJax does not process math that contains HTML tags, so that math is not being typeset.

One solution is to use \_ rather than _ in your equations, as that will prevent Markdown from processing them, and they will be sent to MathJax as plain underscores.

Because the markdown is processed before MathJax sees the page, there is nothing MathJax can do about it. It has to be handled by the markdown engine. My understanding is that kramdown (one of the Markdown engines) is supposed to properly handle this, but I don't have any experience with it myself. There are several tutorials for MathJax in kramdown, so consider this one or this one for more. There seem to be various settings to control the handling of math, so you may need to set one of those.

@dpvc dpvc added the Expected Behavior This is how MathJax works label Feb 23, 2023
@duvelix
Copy link
Author

duvelix commented Feb 24, 2023

Thank you!
I sincerely appreciate your help in resolving this problem.

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