cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Community Member

Best way to add LaTeX equations

I'm a newbie to Canvas. I have found the equation editor, which works fine. But I have pages with many equations. Is there a way to include the LaTeX code in a page, and then have Canvas automatically render the equation? Thanks - this would be a big time saver.

31 Replies
Highlighted
Surveyor

However, I am a math teacher, not a coder. Why doesn't the math equation editor stick to the information typed in? Sometimes the image is fine for the student, sometimes it is not and I cannot tell ahead of time. When I want to do question groups or shuffle answers, this flaw definitely slows down the test taking of the students, since I have to show them a paper copy (also not easy to do) and hope their answers are in the same order as the paper copy.

Highlighted

@rgerritsen yes, you are right. Thank you!

I was looking at the html output itself in Chrome. It works fine within Canvas, after pasting the html file contents into the Canvas html editor.

 

Highlighted

@phonehome, looking at the image you provide I think that you viewed the html in your browser and not withing a canvas environment. MathML (the math markup language used by canvas) is not necessarily natively supported by webbrowsers (I think only firefox has full MathML support). So for the math to work, you need to copy paste the HTML into the HTML editor of canvas and view it as a canvas page. 

If you, however, want to use it to generate HTML that is fully supported by your browser, you could try to delete the MathML option in the textToHtml.py file (it is in the runPandoc function in the args  variable), simply remove the string "--mathml" from the list. It will then default to use MathJax, which I think is more widely supported, but strangely enough not by the canvas HTML environment.

I hope that helps! If I was wrong with the assumption that it is outside the canvas environment let me know, then I will have a more detailed look.

Highlighted
Surveyor

@rgerritsen Thank you for all your great contribution. I hadn't used Python before, so I had to start from scratch and learn some basic things, but for the most part I think I was able to follow your instructions in the LatexToCanvas README file. On Windows10, I installed pandoc, then Python, then added pandocfilters and pygments, then navigated to my LatexToCanvas directory and ran "python textToHtml.py input.tex" (this is the only point where I changed anything: I had to write 'python' instead of 'python3' in my command, because python3 was "not a recognised cmdlet, function, script file, or operable program.")


At the end of all of that, I have a problem. The output.html file that is generated does not display my Latex math. It displays the Latex code itself, rather than the typeset output that you would normally get in a PDF. 

 

Any advice on what is wrong here? Am I missing a step? It seems the latex code hasn't been compiled, so the html is just displaying the code itself, rather than the output. I'm not sure what I am missing...

Highlighted
Surveyor

I also had trouble with adding equations to Canvas pages. Even if you use the equations editor, there is no easy way of adding equation numbers or references to equations. To workaround this I made a LaTeX to plain HTML converter. You put in a LaTeX article and it spits out basic HTML that can be read by the HTML editor of a Canvas page. I'll add a picture of how it can look and if you want to check out the converter visit GitHub.

Highlighted

Dear Uwe:

I tried to make the code a little more useful to anyone by creating this function: Function to convert Latex to Canvas html equation format. · GitHub .

Hope it helps.

David

Highlighted

Now this is very interesting, not to say exciting!

I would really appreciate if there was an LTI for Jupyter (not just a single-cell Sage as there is). I had tried to fool the system previously myself for quizzes with pre-generated LaTeX code, but that did not render at the time.

I will definitely have a look at your code!

Highlighted
Community Member

Hi! I was trying to import some Jupyter Notebooks with Latex code (equations between $ or $$). I managed to do it with a Python3 script. Basically I'm using parse.quote(string, safe='()') two times from urllib library to mimic the equation editor used in canvas. I shared the code in Jupyter notebook with Latex to Canvas html equation converter · GitHub if anyone is interested.

It has some notebook specific cleaning (basically all style and scripts) but it could be adapted to almost any html.

Hope it helps.

Highlighted

Sorry, I edited my post to use the word exit. It was the end of a long day and I meant "cancel" as "exit without saving."

People who are used to using a graphical interface and not the keyboard will use the basic view. Most of my students (first two years of college) right click a mouse to get copy/paste rather than using the keyboard shortcuts. For them, clicking on a √ symbol is a lot easier than typing \sqrt{}.

It's also necessary for people who don't use it often enough to memorize it. Do you want to have students get frustrated learning LaTeX or focus on the material of the course?

Word and WordPerfect both have graphical equation editors in them that don't require LaTeX. For years, I used Design Science's MathType for editing. I created a Mediawiki site for my Differential Equations class about 10 years ago and that's when I really started using LaTeX to render the math content. Then I needed to generate exams programmatically and started using LaTeX full time. When MathType went to a subscription model, I stopped using it, plus it never came out looking good when converting WordPerfect to a PDF anyway.

The reasons for a basic view are many and for some people, they wouldn't be able to enter any math content without it.


For others, the advanced view is a requirement because the basic view just doesn't cut it. The choice of symbols on the palette may make the basic view less useful. It looked like you hesitated in your video when you moused over the \coprod, perhaps thinking "Why is that basic?"  I know I wondered that. On the other hand, the new RCE has moved subscript to now require two mouse clicks and I use that a lot when dealing with systems of equations.

What would be nice would be to have a way to check your advanced LaTeX in New Quizzes without having to save the question first. It would be nice to confirm that you have the correct LaTeX (like the RCE). Maybe show the LaTeX when you're editing between the \( and \) delimiters and render it as math when your cursor is outside the delimiters.

Highlighted

try to exit not cancel the editor before switching to advanced view, i.e. never ever entering advanced view!
In spite of the error message it still works!

(and the question remains: who in their sane mind would ever use the basic view anyway...)

    Uwe.