2

I have been trying to add MathJax to my blog in the "Ghost" platform on the web (not self hosted). I followed some tutorials and I did find out that if I add the code

<script type="text/javascript">
MathJax.Hub.Config({tex2jax: {inlineMath: [ ["$","$"] ], displayMath: [ ["$$", "$$"] ]}});
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

into the "blog header" (that I find in "settings"->"code injection") MathJax works fine for displayed math formulas written between $$. On the other hand there is no way to have the inline math rendered: it doesn't work with the code $...$, (...) and [...]. What am I doing wrong?

Here is my test post on the platform.

0

The current official way to enable MathJax client-side, per their website, is to insert the following code into your header:

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

In Ghost, that's done with the "Inject code" functionality.

There's a choice to be made here: if you only use MathJax in a few posts, use the posts' own "Inject code" functionality. That way, it will only load on pages where it's needed, saving other users (and the MathJax servers) the bandwidth.


Regarding the syntax, the $$...$$ and $...$ syntax is pure TeX, and thus isn't generally recommended for LaTeX anyway (see this question on TeX.SE for reference).

To render properly, one should use the \(...\) syntax for inline math, and \[...\] or \begin{equation}...\end{equation} for displayed math.

Tested on MathJax 3 and Ghost 3.40.2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.