# Community

cancel
Showing results for
Show  only  | Search instead for
Did you mean:
Community Member

## Long Division in Math Editor

I am working with a math course in which students perform long division. Right now the only way to set up long division (even using the equation editor) is to use ) and then and over line. This is tedious and doesn't quite look right. I am wondering if there's another way to create the long division in the latex editor? Also, if there isn't can a long division package be added (such as the one mentioned here: https://tex.stackexchange.com/questions/131125/better-way-to-display-long-division/263931#263931)?

Tags (3)
1 Solution

Accepted Solutions
Community Champion

Long division has always been problematic in LaTeX, as evidenced by the hacks required to get it look right in the TeX exchange you referred to.

The longdiv package is written by Donald Arse­neau, whose name I see all over the place on the TeX exchange for accomplishing magical things and who has written many packages. Longdiv was written in 1994 and really isn't one of his major productions. In other words, he normally has full package documentation. This one is available as just the basic macro. It's not even a long macro, just 42 lines with comments. It does the full division problem, not just the formatting so that it looks nice, although that is part of it as well. I have only played with that one, but I have definitely use the polynom package that does synthetic division.

Neither longdiv nor polynom are mainstream packages, though. Some people would definitely use them, but most of the people using equation editors with Canvas would not. There are several that I would like to see added, including Tikz or PGFPlots. I have even seen some solutions to the long division problem using Tikz. Canvas is trying to achieve a balance between what they think most people will use, what doesn't conflict, and -- in some ways -- what is supported by the underlying software (MathJax). Many of the LaTeX packages cannot be added to MathJax as MathJax only supports math functions and not text. My installation of MiKTeX on Windows has 3554 packages available. The list of MathJax supported extensions and commands is much, much shorter. Some of those are optional packages and I'm fairly sure don't work with the equation editor, but I haven't tested all of them.

Further complicating things is that the longdiv package isn't really a package. You do not invoke it with \usepackage{longdiv}, you use \input{longdiv} instead. People have converted it (here's the longdiv extension for MathJax), but the way it appears on CTAN is not as a package.

As a macro that performs calculations, it has the potential to be used in unintended ways. Since students have access to the equation editor as well, you might give them a problem 123) 456789, and then the student could use \longdiv{456789}{123} and get the answer, defeating the purpose of assessing whether they know how to do the long division.

The answer is that there's not a good way to do long division using the equation editor. This is especially true if you want it to look like how English-speaking countries do long division. There are other forms that are used in other languages. If you don't like the ), Wolfram's MathWorld says that you can use a vertical line instead of a curved one to connect with the vinculum. It may be that you can adopt one of the other formats, although the easiest thing to do is just accept the gap between the ) and the overline.

If you're willing to go outside of the equation editor, you can use CSS to simulate it. For example,

was generated using this code

<p>123<span style="border-top: 1px solid black; border-left: 1px solid black; padding-left: 0.25em; margin-left: 0.25em; padding-top: 0.25em;">456789</span></p>‍‍

The question becomes how do you do this in an accessible manner. What I just did is definitely not accessible, there's not even a mention of division in the problem. It doesn't generate MathML.

You may think that you could generate the problem using MathML instead of LaTeX and the equation editor. Design Science (since bought out by Wiris) has MathML 3 Elementary Math Examples and one of them is long division. Unfortunately, when I try pasting it into Canvas, it comes up with "Unknown node type: mlongdiv" and it doesn't work. Even the example from W3C Working Draft of MathML doesn't render properly in the browser.

If you really need this, you can create a feature idea to request this. Asking whether it can be added or not as part of a question doesn't make it a feature idea where people can vote and voice their support or express dissent. See How do I create a new feature idea in the Canvas Community?

2 Replies
Community Champion

Long division has always been problematic in LaTeX, as evidenced by the hacks required to get it look right in the TeX exchange you referred to.

The longdiv package is written by Donald Arse­neau, whose name I see all over the place on the TeX exchange for accomplishing magical things and who has written many packages. Longdiv was written in 1994 and really isn't one of his major productions. In other words, he normally has full package documentation. This one is available as just the basic macro. It's not even a long macro, just 42 lines with comments. It does the full division problem, not just the formatting so that it looks nice, although that is part of it as well. I have only played with that one, but I have definitely use the polynom package that does synthetic division.

Neither longdiv nor polynom are mainstream packages, though. Some people would definitely use them, but most of the people using equation editors with Canvas would not. There are several that I would like to see added, including Tikz or PGFPlots. I have even seen some solutions to the long division problem using Tikz. Canvas is trying to achieve a balance between what they think most people will use, what doesn't conflict, and -- in some ways -- what is supported by the underlying software (MathJax). Many of the LaTeX packages cannot be added to MathJax as MathJax only supports math functions and not text. My installation of MiKTeX on Windows has 3554 packages available. The list of MathJax supported extensions and commands is much, much shorter. Some of those are optional packages and I'm fairly sure don't work with the equation editor, but I haven't tested all of them.

Further complicating things is that the longdiv package isn't really a package. You do not invoke it with \usepackage{longdiv}, you use \input{longdiv} instead. People have converted it (here's the longdiv extension for MathJax), but the way it appears on CTAN is not as a package.

As a macro that performs calculations, it has the potential to be used in unintended ways. Since students have access to the equation editor as well, you might give them a problem 123) 456789, and then the student could use \longdiv{456789}{123} and get the answer, defeating the purpose of assessing whether they know how to do the long division.

The answer is that there's not a good way to do long division using the equation editor. This is especially true if you want it to look like how English-speaking countries do long division. There are other forms that are used in other languages. If you don't like the ), Wolfram's MathWorld says that you can use a vertical line instead of a curved one to connect with the vinculum. It may be that you can adopt one of the other formats, although the easiest thing to do is just accept the gap between the ) and the overline.

If you're willing to go outside of the equation editor, you can use CSS to simulate it. For example,

was generated using this code

<p>123<span style="border-top: 1px solid black; border-left: 1px solid black; padding-left: 0.25em; margin-left: 0.25em; padding-top: 0.25em;">456789</span></p>‍‍

The question becomes how do you do this in an accessible manner. What I just did is definitely not accessible, there's not even a mention of division in the problem. It doesn't generate MathML.

You may think that you could generate the problem using MathML instead of LaTeX and the equation editor. Design Science (since bought out by Wiris) has MathML 3 Elementary Math Examples and one of them is long division. Unfortunately, when I try pasting it into Canvas, it comes up with "Unknown node type: mlongdiv" and it doesn't work. Even the example from W3C Working Draft of MathML doesn't render properly in the browser.

If you really need this, you can create a feature idea to request this. Asking whether it can be added or not as part of a question doesn't make it a feature idea where people can vote and voice their support or express dissent. See How do I create a new feature idea in the Canvas Community?

Community Member

Thank you James. This is a very thorough answer. I am surprised that a package does not exist that shows long division without showing answers. I appreciate your thoughts and I guess I'll just go with the ) and overline for now. Thanks!