Getting MathJax to work

180 views
Skip to first unread message

Aaron Meurer

unread,
Mar 30, 2014, 1:33:06 PM3/30/14
to nikola-...@googlegroups.com
I am probably doing something stupid, but I can't seem to get MathJax to work in my blog. I have the basic MATHJAX_CONFIG in conf.py, but $math$ won't render. Any suggestions. My blog is at http://github.com/asmeurer/blog.

Aaron Meurer

Damián Avila

unread,
Mar 30, 2014, 1:51:50 PM3/30/14
to nikola-...@googlegroups.com
Your math expressions have the form $latex ...$, it seems that the "latex" prefix is the source of you problems... 


2014-03-30 14:33 GMT-03:00 Aaron Meurer <asme...@gmail.com>:
I am probably doing something stupid, but I can't seem to get MathJax to work in my blog. I have the basic MATHJAX_CONFIG in conf.py, but $math$ won't render. Any suggestions. My blog is at http://github.com/asmeurer/blog.

Aaron Meurer

--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Damián Avila
Scientific Python Developer
Quantitative Finance Analyst
Statistics, Biostatistics and Econometrics Consultant
Biochemist

Aaron Meurer

unread,
Mar 30, 2014, 1:55:45 PM3/30/14
to nikola-...@googlegroups.com
The thing is, it worked at https://github.com/asmeurer/blog/tree/aa04c4308ac78ca4507897e3cd3cb2133c52157d/new_site. I can't figure out why, though. The posts are identical, except I now have a new markdown post, and I tried checking out that exact conf.py and using it, but still the math does not render. I also tried replacing all $latex with $.

The best example is this post http://asmeurer.github.io/blog/posts/2013/03/03/when-does-xlogy-ylogx/. The strange thing is that the math in the first line renders, but no other math does.

Aaron Meurer

Aaron Meurer

unread,
Mar 30, 2014, 2:03:29 PM3/30/14
to nikola-...@googlegroups.com
Consider http://asmeurer.github.io/blog/new_site/output/posts/2013/03/03/when-does-xlogy-ylogx.html, where the math is all rendering (that's just a halfhazard dump of the old thing I referenced, so some stuff won't work under the new_site url). 

Aaron Meurer

Aaron Meurer

unread,
Mar 30, 2014, 2:08:11 PM3/30/14
to nikola-...@googlegroups.com
Ah, I think there's a Sherlock Holmes quote about this. There really was only one thing different between that old site and the new one: the existence of a new Markdown post. I tried deleting this post, and it the math starts rendering again.

So this is obviously a bug. I am using the master branch of Nikola, though I also tried some old tags and it seems to be the same. 

To reproduce:

- Go to https://github.com/asmeurer/blog.  I am on 6bdc97fa556b34a80601ac84dd4dd714f1db6b53.
- nikola build
- Notice the math in output/posts/2013/03/03/when-does-xlogy-ylogx.html
- rm posts/moving-to-github-pages-with-nikola.m*
- nikola build
- Notice the math in the same page

Aaron Meurer

Aaron Meurer

unread,
Mar 30, 2014, 2:10:07 PM3/30/14
to nikola-...@googlegroups.com

Damián Avila

unread,
Mar 30, 2014, 2:11:06 PM3/30/14
to nikola-...@googlegroups.com
Yep, it seems a bug, open an issue at Github please ;-)

Damián Avila

unread,
Mar 30, 2014, 2:11:21 PM3/30/14
to nikola-...@googlegroups.com
Thanks!

Aaron Meurer

unread,
Apr 4, 2014, 8:31:25 PM4/4/14
to nikola-...@googlegroups.com
OK, so I've been playing around with just using MathJax in my Markdown posts. A few comments:

I had to search the code to figure out that to make mathjax work, you have to add "mathjax" to the metadata. It isn't documented. There should be a way to just enable it in conf.py. I want every post that I write to support MathJax. 

I can't get inline math to work with $math$. I figured out that \\(math\\) works, which I guess is a bug (it should require only one backslash). Both $$math$$ and \\[math\\] work for display math.

Aaron Meurer

Damián Avila

unread,
Apr 4, 2014, 9:21:18 PM4/4/14
to nikola-...@googlegroups.com
You are right, it has to be documented...
In my blog I modified the templates of my theme to load mathjax in all my post... but maybe an overall option inside conf.py could be a good solution... In general, we are conservative at the time to add new options inside conf.py... but now we have more math users... maybe it worth to have that option next to the MATHJAX_CONFIG option... 

And the inline math is probably a bug as you said...

Thomas Mansencal

unread,
Dec 3, 2015, 1:52:26 AM12/3/15
to nikola-discuss
Was the inline Mathjax issue fixed? I have a similar one with IPython Notebooks, they don't convert properly from Nikola, however invoking jupyter nbconvert from the command line produce a correct html output.

Cheers,

Thomas

Chris Warrick

unread,
Dec 3, 2015, 12:14:37 PM12/3/15
to Nikola—Discuss
On 3 December 2015 at 07:52, Thomas Mansencal
<thomas.m...@gmail.com> wrote:
> Was the inline Mathjax issue fixed? I have a similar one with IPython
> Notebooks, they don't convert properly from Nikola, however invoking jupyter
> nbconvert from the command line produce a correct html output.
>
> Cheers,
>
> Thomas

How do you use maths in your notebook? If you use $dollars$, you need
to change your mathjax config (a snippet is waiting to be uncommented
in conf.py). Otherwise, it should work just fine.

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

Thomas Mansencal

unread,
Dec 4, 2015, 12:44:54 AM12/4/15
to nikola-discuss
Unfortunately snippets enabled or not, the inline mathjax is still not accounted for. The inline \\math\\ form doesn't work either. This is the snippet I use (default from current conf.py):

MATHJAX_CONFIG = """
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\\(","\\\)"] ],
        displayMath: [ ['$$','$$'], ["\\\[","\\\]"] ],
        processEscapes: true
    },
    displayAlign: 'left', // Change this to 'center' to center equations.
    "HTML-CSS": {
        styles: {'.MathJax_Display': {"margin": 0}}
    }
});
</script>
"""

Cheers,

Thomas

Chris Warrick

unread,
Dec 4, 2015, 3:34:59 AM12/4/15
to Nikola—Discuss

This is not an inline math form. Try this:

\(math\)

Which may need to be changed to:

\\(math\\)

in some circumstances (input format using backslash to escape things).
If you still experience problems, pastebin a broken .html output file and post the link here.

--
Chris Warrick <https://chriswarrick.com/>

Sent from my Galaxy S3.

--

Thomas Mansencal

unread,
Dec 4, 2015, 6:28:27 PM12/4/15
to Nikola—Discuss
Thanks Chris!

Using the form with parenthesis (the corrected one) seems to partially work: I'm facing problems with some latex constructs that fails even at the notebook level. This snippet illustrates the issue:

$M_{RED\rightarrow RGB}$, $M_{XYZ\rightarrow RGB}$ # Fine

\\(M_{RED\rightarrow RGB}\\), $M_{XYZ\rightarrow RGB}$ # Fine

\\(M_{RED\rightarrow RGB}\\), \\(M_{XYZ\rightarrow RGB}\\) # Broken

Here is my stack for info:

Server Information:

You are using Jupyter notebook.

The version of the notebook server is 4.0.6 and is running on:

Python 3.5.0 |Anaconda 2.4.0 (64-bit)| (default, Oct 19 2015, 21:57:25) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]

Current Kernel Information:

Python 3.5.0 |Anaconda 2.4.0 (64-bit)| (default, Oct 19 2015, 21:57:25) 
Type "copyright", "credits" or "license" for more information.

IPython 4.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
%guiref   -> A brief reference about the graphical user interface.

As this is likely an issue on Jupyter side, I'll raise an issue there and report.

Cheers,

Thomas

You received this message because you are subscribed to a topic in the Google Groups "nikola-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nikola-discuss/yM8yoFvckbM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nikola-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages