LaTeX Math for e-Learning in D2L

I am teaching MCF3M online this semester, so I need to be able to include math notation in my online content, quizzes, etc. I know how to write math notation using LaTeX from my days at the University of Waterloo, and I find it a lot faster than using a graphical equation editor. I’ve tried Microsoft Word’s editor, which accepts LaTeX-like input as well as graphical input, but I still find it frustrating to use.
I’m teaching in the Desire2Learn/BrightSpace learning environment, so I need to ensure my content works well in there. Last semester I taught Computer Science/Programming and used PDF files that I created in Word Online, and I considered doing the same thing again.

But D2L has an equation editor as part of its HTML editor for webpages, discussion posts, etc. Could it be all I need?

I’ve taken it for a spin before. Here’s the workflow:

Create a new page and type into the HTML editor.

latex01

Expand the toolbar so that the Equation tools are available.

latex02

Choose \∑ LaTeX equation.

latex03

Type in the LaTeX expression, using \( and \) as delimiters for inline mode (otherwise it defaults to block mode).

latex04

latex05

Looks good.

latex12

But look at the source HTML code:

latex07

Uh-oh… that’s MathML (Math Markup Language), not LaTeX. What if I want to change something in my original LaTeX?

Well, you can see at the bottom that my LaTeX code is still there, but it’s not being used. I could remove all the MathML, cut out my LaTeX, modify it, and re-insert it using the LaTeX equation editor.

Ugh.

I thought that MathJax, the rendering engine that D2L uses for math notation, could only handle MathML (since notation from both LaTeX and graphical editors are converted to MathML), but it turns out that’s not true. MathJax can do LaTeX.

So I tried putting LaTeX directly into the WYSIWYG editor:

latex10

No dice.

latex11

The trouble is that D2L has parameters on its JavaScript call to MathJax:

latex08

That config=MML_HTMLorMML bit is saying that only MathML is acceptable input (and HTML or MathML can be output).

So I added another call directly to MathJax in my own source code:

latex09

I set the parameter to be config=TeX-AMS_HTML, which will accept my LaTeX input and render in HTML/JavaScript.

latex12

Magic.

But this is kind of a pain.

I can use D2L’s editor to insert math, but I get MathML (which I find hard to edit).

I can write in LaTeX and have it be preserved, but I need to add a script call to the start of the HTML source code (a hassle, but not too serious, I suppose).

Or I can write in some other (offline) development environment, include my script call all the time, and just upload my completed HTML files to my course. This has the advantages of being independent of D2L, available without internet access, and very shareable.

So that’s what I’ve decided to do, at least for now. So I’ve learned a little CSS to make my pages less vanilla/more functional, and I’ll try to improve the look and feel as the semester progresses.

Wish me luck.

Advertisements

A Sample Proof Using Mathematical Induction (playing with LaTeX)

It’s been a long time since I used LaTeX regularly, and I discovered that I don’t have any leftover files from my days as a math student in Waterloo. After looking at LaTeX in the context of D2L today, I dug out a unit plan I had written for MGA4U (extinct) in 2003 using the Ontario Curriculum Unit Planner (also extinct).

First it’s worth noting that I had no idea what good assessment looked like. It’s almost 11 years ago, but it feels like a lifetime when I look at the awful way I was planning to assess students. This was a unit I developed while practice teaching. I’m really, really glad my practice doesn’t look like that now.

Anyway, I found a page (“S2 Teacher Resource 1.pdf”) which I had typeset using LaTeX. I thought I’d try to reproduce the mathematical proof on the page to see if I could remember how. Here’s a picture of the page:

A photo of a sample proof on paper

I left off the trimmings and tried to write the middle. I can’t remember how to indent things the way I did before, so I’m settling for something different (feel free to educate me, though).

I used the JaxEdit LaTeX Editor at http://jaxedit.com/note/ to create the document:

\documentclass[letterpaper]{article}
\newtheorem{thm}{Theorem}
\newproof{proof}{Proof}
\begin{document}
\title{Sample Proof Using Mathematical Induction}
\author{Brandon Grasley}
\date{2014-01-21}

\titlepage
\begin{thm}
\\For any $n \in \mathbb{N}$, 
\[$\sum_{i=1}^{n}i=\frac{n\left ( n+1 \right )}{2}$\]
\end{thm}
\begin{proof}
\\Base case $n=1$: If $n=1$, the left side is 1 and the right side is $\frac{1\left ( 2\right )}{2}=1$.
So, the theorem holds when $n=1$.
Inductive hypothesis: Suppose the theorem holds for all values of $n$ up to some $k$, $k \geq 1$.
Inductive step: Let $n=k+1$. Then our left side is
\begin{align}
$\sum_{i=1}^{k+1}i&=\left (k+1\right )+\sum_{i=1}^{k}i\\
&=\left (k+1\right )+\frac{k\left ( k+1 \right )}{2}$\text{, by our inductive hypothesis}\\
$&=\frac{2\left (k+1 \right )}{2}+\frac{k\left (k+1 \right )}{2}\\
&=\frac{2\left (k+1 \right )+k\left (k+1 \right )}{2}\\
&=\frac{\left (k+1 \right )\left (k+2\right )}{2}$
\end{align}
which is our right side. So, the theorem holds for $n=k+1$. 
By the principle of mathematical induction, the theorem holds for all $n \in \mathbb{N}$.
\end{proof}

\end{document}

This generated a page like this:

An image of the proof rendered from LaTeX

 

I’m definitely surprised at how hard it is to find free, online LaTeX renderers. I ended up taking screen shots of that output in order to post it here. The others I found either require sign up or didn’t successfully render all of the math components.

Well, something to keep exploring. I wonder if I’ll start working in HTML with MathJax instead, using D2L as the authoring platform. We’ll see.