Degree symbol command for mathjax in Canvas quizzes

Jump to solution
rmiller6dcsdk12
Community Member

I know that Canvas/Instructure recently began mathjax support (thank you thank you thank you sooooo much). I also know that the \degree is fairly new to mathjax. I noticed that canvas does not support the \degree command and instead we have to exponentiate a circle like so: \ (30^{\circ}\ )

Is there any plans to impliment the \degree command or any better ways to do this. I also come from a time before graphical editors and I really find it easier to just type out the command. Clicking on stuff to bring up a degree symbol really breaks my flow and slows me down.

Labels (1)
0 Likes
1 Solution
James
Community Champion

@rmiller6dcsdk12 

I'm definitely with you on the preferring to type things out.

I cannot speak for Instructure, but I would guess they are not planning on implementing gensymb to get the \degree symbol. Let me explain why I think this and then give you some alternatives.

MathJax support in Canvas has been around for a while. It was under the hood with the equation editor and then, I think in 2021, they added the ability to add math content anywhere using the delimiters \ ( and \ ).

Note: R. Miller knows that the Community software renders math, so wisely put a space between them to keep it from doing so. For others finding this thread, the actual delimiters do not have a space between the \ and ( or ).

I remember adding MathJax myself so I could quickly write my lecture notes when COVID hit and by Fall 2020, all of my classes used my version. Within a year, I had to remove my version and retype some things since Canvas added their own version.

The version of MathJax being loaded by Canvas is 2.7.7, which is several releases behind. Version 2.7 is the latest branch of MathJax 2, but the current version is MathJax 3.2. Anytime there is a major upgrade, there is a chance of breaking something, so it would need to go through rigorous testing before being upgraded. There is a warning about upgrading that says it is not a drop-in replacement. There is also a note about lack of support for some of MathML in version 3. Since Canvas is all about accessibility and MathML is the right way to mark up math on the Web, they may be holding back until that is ready.

In specific regard to \degree symbol, it is only supported if you load the gensymb package. That package adds \celsius, \degree, \micro, \ohm, and \perthousand. The MathJax documentation says that the gensymb package is not autoloaded. That means that you would need to be able to tell Canvas which extensions to load in order for it to be supported.

When I was loading my own MathJax, I was able to load libraries, extensions, and packages that I wanted to use that were not support by Canvas. I stopped looking for a way to inject my libraries into their code once it became globally available and decided to just use the supported code.

You can put in a feature request to add the \degree symbol, but it's unlikely to be there. Canvas will just say that it's already in the equation editor. Picking the degree symbol uses the ^{\circ} trick that you mentioned.

However, there is an undocumented trick you can use. I used this with my own version of MathJax that I had in 2020 and it worked there. So it's more of a MathJax hack than a Canvas hack.

You can define \degree before you use it and then use it anywhere on the page. It would need to be loaded on any page that you need the symbol, though, as it gets loaded when MathJax encounters it for the first time. If you try to use the \degree before defining it, you get the current behavior where it shows \degree in red.

For example, here are two lines that work as you suspect they would.

<p>\(\def\degree{^{\circ}}30\degree\)</p>
<p>\(45\degree\)</p>

\def overrides macros without warning, so if Canvas ever does include the gensymb package, you'll end up using your definition instead of theirs, but it still works.

\def doesn't allow you to supply parameters, so you might be wondering about \newcommand. It turns out that \newcommand and \renewcommand work in the same way as \def.

When I was writing my calculus 3 notes, I had a lot of vector symbols. I did not want the harpoon that \vec gives you, I wanted a bold, roman (non-italic) font. Since \vec is an existing macro, I needed to use \renewcommand. If you do it once per page, then you can use it at any point after that on the same page.

<p>\(\renewcommand{\vec}[1]{\mathrm{\mathbf{#1}}}\vec{u}\)</p>
<p>\(\vec{v}\)</p>

 

Although you could use \renewcommand, when I rewrote my notes to use the Canvas-supplied MathJax, I took out all of my existing macros. Instead, I used a keyboard shortcut program to put in the \mathrm\mathbf{}} and then arrow left two times so I was inside the braces. You could do something similar with the ^{\circ}. Set something like Shift+Alt+D to execute the keyboard macro and give you the symbol.

Another possibility is to put ^{\circ} into the clipboard and then press Ctrl+V every time you need it. If you already have \degree on the page, you could search for \degree and when it's found, replace it. Since the browsers don't support find and replace, I normally take my text, copy and paste it into a text editor, do the search and replace, and then copy and paste it back into Canvas.

There are some browser extensions to add search and replace capability. A potential problem there is that you need to make sure that it only changes the text in the Rich Content Editor and not elsewhere on the page. It may not matter for \degree, but someone else reading this might want to change other things.

View solution in original post