Using Math in Moodle

If you’re like me and interested in using math notation in Moodle, I believe you have 2 options. The first option is to use the TeX filter that is in Moodle. This is a LaTeX type editor. To enable, go to site administration -> plugins -> filters
TeX in Moodle:
And more notation info:

The big problem with TeX in my mind is that it is a bit awkward to use. However, if the range of notation that you want is narrow, you can quickly learn how to input what you need.

I think the better option is to use ASCIIMathML because it is easier to use, is more intuitive and also looks better. However, one of the big problems with ASCIIMathML is that it only works with Firefox. No other browsers are able to display its notation without other plugins. There are two workarounds for this. First, you can demand that users use Firefox. Secondly, you can use a version of ASCIIMathML that has a “fallback.” How the fallback works is if the browser does not display the ASCIIMathML correctly, it automatically switches to displaying LaTex images.

First let’s start with the ASCIIMathML. You can find a bit of information about it here, including a link to download:
I found this thread on the Moodle forums to be very helpful:
For my examples below you have to include a javascript file inside your Moodle installation. I am assuming that you are putting the ASCIIMathML.js file in the folder:


Adjust this url with your own domain.

To get asciimath working in Moodle 2.0, go to site administration -> Appearance -> Additional HTML
In the “Within HEAD” section, paste the text:
<script type=”text/javascript” src=””></script>

What this does is ensures that the ASCIIMathML javascript is inserted into the head of every html page.

If you don’t have Moodle 2.0, you have to find your config.php file for your theme and insert the text there. For example, if you are using the theme FormFactor, go to the file:
Open the config.php file in an appropriate editor (I use Codelobster) and somewhere between
<head> and </head> insert the line:
<script type=”text/javascript” src=””></script>

In firefox you should now be able to use ASCIIMathML notation. I had an additional problem and had to edit my asciimathml.js file. Somewhere around line 50 in this file I had to change
var avoidinnerHTML = false;
var avoidinnerHTML = true;

Okay, now that it’s working you can try a fallback version. I used ASCIIMathMLwFallback2.js from

I edited the same “avoidinnerHTML” in the .js file, uploaded it to the same /lib/asciimath folder, and edited the “Within HEAD” section to use the new javascript file name. I now have ASCIIMathML working on all browsers. More info on fallback can be found at this Moodle forum link:

Leave a Reply

Your email address will not be published. Required fields are marked *