Search code examples
javascriptlatexmathjaxhexo

How to fix "ignoring to render a piece of mathjax code in Hexo"?


A line of mathjax code cannot be rendered into the correct math formula, shown in its original code in the blog. However, there does not exist grammar mistake in this piece of code which can be rendered correctly in the online Markdown website like StackEdit. What's more, except this line of code, all other mathjax code in the same Markdown file can be rendered formally.

I am writing a Hexo blog with a great number of math formulas.

$$ \Vert W^{[l]} \Vert\\_ {_F} ^2 = \sum\\_ {i=1}^{n^{ [l-1] }} \sum\\_ {j=1} ^{n^{ [l]} } ( W\\_ {ij} ^{ [l] } ) ^2 $$

Solution

  • Looking at the page as displayed in your screenshot, you can see that some characters in the un-typeset expression are in italics, and others are in a superscript position. That suggests that your content management system (Hexo?) is inserting HTML tags into the expression before it ships the page to the browser. For example, between the _ in {_F} and the following one at \sum\\_ is all in italics, and the underscores are missing, which suggests that the underscores have been replaced by <em> and </em>. Similarly, the ^{n^ seems to have been replaced by <sup>{n</sup>.

    MathJax will not process math that contains HTML tags; the math must be entirely plain text. So that would explain why that expression is not being typeset. It looks like you may have tried to use backslashes to prevent them from having their usual effect, but it seems that you have doubled the backslashes, when you probably only needed single ones. Try

    $$ \Vert W^{[l]} \Vert\_{\_F} ^2 = \sum\_{i=1}\^{n\^{[l-1]}} \sum\_{j=1}\^{n\^{[l]}} (W\_{ij}\^{[l]})\^2$$
    

    instead.