LaTeX Questions Answered

51 How do I create a long division equation in LaTeX?

Last update: Jan 16/23

Long division requires a LaTeX extension. To load the extension, use the \require command to load the \enclose extension that allows you to access MathML elements, including long division \longdiv. An extension only needs to be loaded once, then it would be available for the entire book in Pressbooks.

For the first time, write \require{enclose}5\enclose{longdiv}{25}. It looks like:


After that, write as divisor\enclose{longdiv}{dividend}. Using the same example 20 ÷ 5, write 5\enclose{longdiv}{20}. It looks like:


If you need to include the quotient and the process of long division, combine with the \begin{array} or \begin{align} command (for more information, see How do I create an array using LaTeX?)

[latex]\begin{array}{r}\text{quotient}\\ \text{divisor}\enclose{longdiv}{\text{dividend}}\end{array}[/latex]

The process of 20 ÷ 5 = 4 with the remainder of 0 would be written as \begin{array}{r}4\\ 5\enclose{longdiv}{20}\\20\\ \hline 0\end{array}.

[latex]\begin{array}{r}4\\ 5\enclose{longdiv}{20}\\-20\,\\ \hline0\,\end{array}[/latex]

Here is an example of a long division question solved that has a remainder:

[latex]\begin{array}{l}\hspace{0.7cm}32\text{ R}3\\8 \enclose{longdiv}{259}\\\hspace{0.1cm}-24\\\hline\hspace{0.8cm}19\\\hspace{0.4cm}-16\\\hline\hspace{1cm}3\end{array}[/latex]


Icon for the Creative Commons Attribution 4.0 International License

Pressbooks Guide Copyright © 2016-2022 by OER Production Team is licensed under a Creative Commons Attribution 4.0 International License, except where otherwise noted.

Share This Book