How to Enable MathJax Rendering in Sublime Text Ma

2020-06-09 04:27发布

Using Sublime Text 3, I'm writing a Markdown document that includes math. The Markdown Preview package enables real-time rendering of the document in the browser (Chrome). So as I write, the changes are visible. The following is my markdown text.

$a = \sin^{2}(\Delta \phi/2) + \cos(\phi_{1})\cos(\phi_{2})\sin^{2}(\Delta \lambda/2)$
$c = 2 \arcsin(\sqrt{a})$
$d = rc$

MarkdownPreview manual says something like "When enable_mathjax is true", but I cannot figure it out where it is. For completeness, The Sublime console does not display any error message. I'm using Windows 7 and the lastest MathJax fetched from Git. MathJax itself works fine when I displayed some sample test html.

3条回答
欢心
2楼-- · 2020-06-09 05:09

As of now, neither of the above answers is working anymore. I finally found a solution in a Github issue which provides an updated version of the code snippet that needs to be added to the MarkdownPreview user settings:

"js": [
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js",
        "res://MarkdownPreview/js/math_config.js",
],
"markdown_extensions": {
    "pymdownx.arithmatex": {
        "generic": true
    }
}
查看更多
Root(大扎)
3楼-- · 2020-06-09 05:11

Providing MarkdownPreview is installed correctly, one can find option enable_mathjax this way:

enter image description here

Hope this helps.

查看更多
女痞
4楼-- · 2020-06-09 05:14

The MarkDown Preview 2.x branch won't work with the method in @VividD answer.

My User Settings, which enables MathJaX is as following:

{
    "enable_mathjax": true,
    "js": [
    "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js",
            "res://MarkdownPreview/js/math_config.js",
    ],
}

Also, using Package​Resource​Viewer I edited the math_config.js in the js folder of MarkDown Preview to make the Display Math aligned to center:

MathJax.Hub.Config({
  config: ["MMLorHTML.js"],
  extensions: ["tex2jax.js"],
  jax: ["input/TeX", "output/HTML-CSS", "output/NativeMML"],
  tex2jax: {
    inlineMath: [ ['$','$'], ["\\(","\\)"] ],
    displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
    processEscapes: true
  },
  TeX: {
    extensions: ["AMSmath.js", "AMSsymbols.js"],
    TagSide: "right",
    TagIndent: ".8em",
    MultLineWidth: "85%",
    equationNumbers: {
      autoNumber: "AMS",
    },
    unicode: {
      fonts: "STIXGeneral,'Arial Unicode MS'"
    }
  },
  displayAlign: "center",
  showProcessingMessages: false,
  messageStyle: 'none'
});

Pay attention to displayAlign. At default it is displayAlign: "left".
You can customize MathJaX farther according to MathJaX Options.

查看更多
登录 后发表回答