Skip directly to content

Error message

The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.

Adding MathJax to DrupalGardens

on December 4th, 2012 at 3:19:30 AM

So let's say you are a geek/nerd in the Math/Physics sense. You have been constantly wondering why not everyone uses LaTeX to write everything. Sadly, when you hit the web you are even more distressed because the last thing you want to do is old school ASCII art. Well thanks to MathJax your sites can look like

So to get this going was actually straight-forward

  • Add MathJax to your site using javascript libraries as the external URL use http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
  • place the library in the header region
  • create a text formatter (MathHTML) that does nothing
  • write your equation-fu using something like
     <script type="math/tex; mode=display">
    \begin{aligned}
    \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
     \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
    \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
    \nabla \cdot \vec{\mathbf{B}} & = 0
     \end{aligned}
    </script>
    

    The math/tex sets TeX mode, mode = display means a TeX display equation vs. leaving out mode=display and getting an inline equation
The info that I used to hack around MathJax

Post new comment