How do I get MathJax to enable the mhchem extension in ipython notebook
Question: Okay, this has been a very frustrating adventure for me. I have spent many
hours over several successive days trying to get MathJax to enable and
recognize the mhchem extension within a Markdown cell in ipython notebook.
Math expressions worked fine, but the mhchem macros `\ce` `\cf` `\cee` just go
unrecognized. I have tried enabling the extension in the
`MathJax/config/default.js` file. I tried putting the following script code
with the Markdown window

    
    
    <script type="text/x-mathjax-config">
    MathJax.Hub.Config({TeX: {extensions:["TeX/mhchem.js"]}
    ...
    });
    </script>
    

I have tried every trick and tip I could find on the internet. Nothing seems
to work.

I am running debian wheezy. I thought maybe the default mhchem and MathJax
packages were causing the problem, so I installed a custom version of MathJax
for ipython notebook into my profile_default/static directory and configured
ipython to use this. Again, math fine, chemistry a no go. I am able to use the
mhchem extensions directly from TeX but MathJax just refuses to load the
extension or recognize the `\ce` tags.

I am stumped!

Anyone have any ideas?


Answer: Thanks for your answer. I had tried loading the script with an without the
`Tex/`. I had tried `/ce` `\ce`. Just about everything imaginable. I finally
found a solution and it was as follows:

If I use the 'non-standard' `/require` macro within a math expression to force
load the mhchem extension everything works great.

I added the following code at the top of the Markdown cell

    
    
    $$\require{mhchem}$$       
    

Strangely, once I have done this in the first line of the first markdown cell,
it seems to work flawlessly throughout the notebook. Even from within a code
page where I was executing the following to test the mhchem extensions:

    
    
    from IPython.display import display, Math, Latex                                                                                                                                                                                             
    display(Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx'))                                                                                                                                                                     
    display(Math(r'\ce{H2O}'))   
    

Without the `/require` macro, the above code would generate the math function
correctly but the chemistry formula would simply be rendered as '\ceH2O'

By including the `/require` line, all mhchem usage in the notebook seems to
work fine.

Also, I should note that I was running the ipython packages installed from the
Debian Jesse repositories. Turns out that is still 0.13. In the end, I removed
these packages and installed 1.10 directly using the setuptools. The MathJax
worked out of the box with this install.

Anyway, hopefully, this will save some other poor chemistry user some
frustration

