Forum Discussion
How to add Accessible Mathematics to your rise course. (Including Super and Sub Scripts and Formulas)
- 7 months ago
Hello everyone, 🎉
I’m happy to let you know we released a new update for Rise 360. This update adds the following feature:
- Build math equations using LaTeX syntax and revise them by adding color and alt text.
There’s nothing to install for web apps. New features and fixes are immediately available, though you might need to publish your Rise 360 course again.
Let me know if you have any questions about this update or the new feature.
Here's the code for MathJax version 3. You can put this in the head section of the index.html page and don't have to worry about messing with the bundle.js file.
Edit: updated 5/19/20 after scripts started breaking - This is the risk of users having to implement workarounds to get this functionality. Articulate stores the lesson content in JSON which is BASE64 encoded and stored in a variable on the index.html page. It must decode and parse the JSON and dynamically load the content to the page after the page is loaded. It would be great if Articulate could provide us with an event we could hook into when the content is finished loading to the page. At that point we could simply call MathJax.typeset();
or MathJax.typesetPromise();
instead of haphazardly trying to detect DOM changes which is VERY inefficient.
<script>
var mathJaxPromise = null;
MathJax = {
tex: {
inlineMath: [['\\(', '\\)']]
},
startup: {
ready: () => {
MathJax.startup.defaultReady(); // Make sure MathJax is initialized
// Whenever there's a DOM change, check the dynamic content for LaTex
var observer = new MutationObserver(function () {
if (mathJaxPromise) {
mathJaxPromise.then(function () {
mathJaxPromise = MathJax.typesetPromise();
});
}
else {
mathJaxPromise = MathJax.typesetPromise();
}
});
observer.observe(document.body, {
attributes: true,
attributeFilter: ["id", "dir"],
attributeOldValue: true,
childList: true
});
}
}
};
function typeset() {
MathJax.startup.promise = MathJax.startup.promise
.then(() => MathJax.typesetPromise())
.catch((err) => console.log('Typeset failed: ' + err.message));
return MathJax.startup.promise;
}
// Check for changes in the hash location in the address bar
addEventListener("hashchange", (event) => {
typeset();
});
</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<!-- Uncomment one of the scripts below to use either chtml or svg. I defaulted to SVG for widest support -->
<!-- svg (use scalable images) -->
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-svg.js"></script>
<!-- chtml (use html/fonts and css (beware of EDGE) -->
<!-- <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> -->
Edit: 1/29/2024 - Updated to account for breaking changes. This now detects changes in the # location in the address bar to reapply mathjax.
Thank you so much for the update Zachary, it is very much appreciated!
- CarolKinnard2 years agoCommunity Member
Thanks Zachary we are halfway there! This fixes the block MathJax but inline is still broken. The $ notation has been removed from the script but we do use inline equations throughout our curriculum, more that the block notation.
Hoping we can continue to make progress,
Carol - CarolKinnard2 years agoCommunity Member
Hi Zachary,
After some research, I found that the backslash paren notation works. This is great news and you can consider this fix fixed.
Thank you for your diligence and response to our problem!
Sincerely,
Carol Kinnard- JasonLaMar-c69c2 years agoCommunity Member
Carol,
To help make this a bit more "consistent" (such as it is), I changed line 5 of Zachary's code to this instead:
inlineMath: [['$$$', '$$$']]
That way, if you use $$ on either side of the MathML code, it outputs the math on its own line. But if you just add one more dollar sign and use $$$ on either side of the MathML, it outputs the math inline.
It's a small detail, of course, but for me (and my instructional designer colleagues) it's easier to remember multiple dollar signs -- as long as you don't get mixed up on which one displays inline versus on its own line. :-)