# Using Mathjax and Markdown in WordPress

I just started my own WordPress page and came across several different tutorials to use Mathjax and Markdown in my blog.
The easiest and most convenient way to do this is probably the following:

# Markdown

To use Markdown you can simply install the Jetpack plugin, which includes not only Markdown support but also security fixes, some overview about your site’s traffic, social media link options and much more.
It was written by the developers of WordPress and will register your site to the WordPress database. Once you have installed and registered Jetpack you will see a new entry in your sidebar of your admin page

From here go to

Jetpack -> Settings -> Writing


and activate the option “Write posts or pages in plain-text Markdown syntax”:

To activate Markdown support also in your comments and discussions go to

Jetpack -> Settings -> Discussion


and activate the option “Enable Markdown use for comments”:

For a quick reference on all the features, I suggest the WordPress reference on Markdown.

# Mathjax

There are also plugins for Mathjax but the easiest way to use it is to just add it to your header file in WordPress.
To do that go to

Appearance -> Theme Editor -> Theme Header (header.php)


You then have to edit that file. Search for the tag

</head>


and insert just before it

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\$","\$"] ],
processEscapes: true
}
});
</script>

<script type="text/javascript"
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


The first script environment tells Mathjax to recognize $...$ as inline math environments. By default this syntax is not enabled.
The second script environment actually loads Mathjax with the corresponding config file TeX-AMS-MML_HTMLorMML which enables Latex, AMS-math and CSS or MathML based rendering.
For more reference on that check out the Mathjax documentation.
You now have a working Mathjax installation.

There are however some things to note here:

• Due to the combination of Mathjax and Markdown you should escape backslashes. E.g. when you would write in Latex you should actually write \. If you don’t, Markdown will sometimes misinterpret characters like { as { and will then pass it to Mathjax, which will throw a syntax error.
• Because we wanted to use $...$ as an inline math environment, we have to escape every ordinary occurrence of a dollar sign by \$. If you don’t want that behaviour just remove the corresponding part in the configuration of Mathjax (see above).

That’s it! You now have a fully working Markdown and Mathjax environment.

## One Reply to “Using Mathjax and Markdown in WordPress”

This site uses Akismet to reduce spam. Learn how your comment data is processed.