MathJax and ASCII Math

Jump to solution
cnordick
Community Explorer

I know that I can use Canvas to render Latex equations and this is done using MathJax. Mathjax also renders ASCII math equations (which I just find so much easier to use) and is instigated using the ` ` character (`3/4` for example). If I use this character (`) in a Canvas textbox it does not render. However, if I place $$ $$ somewhere else in the textbox and then use ` ` it does render. I know that this $$ $$ characters is how you instigate a Latex equation but this seems to be the only way to start mathjax. It would be nice if Canvas would start Mathjax equation rendering with the ` ` character as well. This is how it works in other applications where I have used Mathjax. 

0 Likes
1 Solution
James
Community Champion

@cnordick 

Canvas does support AsciiMath. They use version 2.7.7 of MathJax with the TeX-MML-AM_SVG configuration. The AM means that it would support AsciiMath.

Here's the catch -- Canvas needs to know that there is math content on the page in order for it to load MathJax. That means that AsciiMath cannot be the only way that math content is created on the page.

There are two ways that I know of to execute MathJax's processor on a Canvas page. The first is to use the \ ( and \ ) delimiters (I added a space so the Community software doesn't try to render it as MathJax). The second is to use the equation editor to create an equation image. There was a time when the second way was more reliable with the mobile app. I'm not sure if that's still an issue, but I tell my students not take my math quizzes with the Canvas app (for a few reasons).

You could enable MathJax by going to the bottom of your page and add this. Although it should render as nothing, I'd put it at the bottom rather than the top. Again this is only necessary if there's no other math content on the page.

 

\(\)

 

 

Once Canvas detects one of those items, then it loads MathJax and MathJax picks up the backticks for AsciiMath and shows your `3/4` as \(\displaystyle\frac{3}{4}\).

Backticks can be used for other purposes that would make you not want to render them unless there was also math content on the page. Similar to the dollar sign, it's too frequent and not unique enough to be a delimiter on its own. For example, JavaScript uses the backtick for template literals. If you have 

 

console.log(`${name.last}, ${name.first}`)

 

on a page with math content, the backtick will kick it into MathJax mode and it will look not-at-all like you want. Note that including it in a preformatted block (good idea for any code), keeps it intact and the backticks are not recognized as AsciiMath.

While backticks are not good for delimiters, the \ ( and \ ) are widely recognized as LaTeX delimiters -- even if you use $ and $ in your own documents where you know you won't be using the $ for dollars.

Backticks are not universally recognized as AsciiMath -- even when MathJax is loaded on the page. Besides the preformatted block I mentioned, backticks are used in New Quizzes to identify variables in formula questions. Because the \ ( and \ ) are used for MathJax, this allows you to use variables within LaTeX. That's pretty cool because now you can do things like

 

Give the angle in degrees to the nearest tenth.

\(\sin^{-1}`x`\)

 

and have the math show up as \(\sin^{-1}0.976\).

View solution in original post