19

I'm currently in the process of trying to create a worksheet for my students with long division problems for them to practice. Unfortunately, the best I've been able to come up with so far in terms of displaying long division like how they write it is:

example

Which could work if need be, but I thought I'd see if anyone has tooled around with this and come up with something better. To create that, all I did was type:

$\overline{)12345}$

Any suggestions for ways of making that better (so it looks more like what'd you see when using \longdiv) would be awesome.

  • I'm not somewhere I can check, but if I remember correctly, kicking up the parenthesis by one size improves the appearance. a solution was published in tugboat years ago. – barbara beeton Sep 2 '13 at 0:07
  • To add to Barbara's comment: here is what I did: \newcommand[2]{\longdiv}{#1\ \overline{\smash{\Big)}\ #2}} and it closed the gap. – user28549 Sep 2 '14 at 21:24
  • Using \overlinegenerally does not produce pretty results with shorter characters. This applies to many of the answers given below. – Andrew Uzzell Jan 6 '17 at 21:27
16

You can give a definition of a command inspired by the one used in longdiv.sty; something along these lines:

\documentclass{article}

\newcommand\Mydiv[2]{%
$\strut#1$\kern.25em\smash{\raise.3ex\hbox{$\big)$}}$\mkern-8mu
        \overline{\enspace\strut#2}$}

\begin{document}

\Mydiv{56}{3678}\quad\Mydiv{3}{37678}

\end{document}

enter image description here

| improve this answer | |
  • @Gonzalo_Medina Thanks for the answer, how would I write numbers on top of the line? – Jamie Twells Dec 30 '14 at 16:50
  • Never mind, like this: $$ \begin{array}{r} 0 \\ \Mydiv{8}{3} \end{array}$$ and remove all the $ from the command :) – Jamie Twells Dec 30 '14 at 17:27
  • Nice looking long division symbol... now, please convince the owner of polynom package to fix it so long division doesn't negate all the products on each line. :D – Jeff Oct 25 '15 at 5:55
20

I got really prefectionisty about this once upon a time, and created a tikz-based solution:

\documentclass[border=4pt]{standalone}
\usepackage{calc}
\usepackage{tikz}

\newcommand{\longdivision}[2]{
    \settowidth{\dividendlength}{#1}
    \settowidth{\divisorlength}{#2}
    \settoheight{\dividendheight}{#1}
    \settoheight{\maxheight}{#1#2}
    \settoheight{\divisorheight}{#2}

    \begin{tikzpicture} [baseline=.5pt]
        \node at (-.5*\divisorlength-1pt,.5*\divisorheight) {#2};
        \node at (.5*\dividendlength+5pt,.5*\dividendheight) {#1};
        \draw [thick]  (0pt,-.22*\dividendheight) arc (-70:60:\maxheight*.41 and \maxheight*.82) -- ++(\dividendlength+7pt,0pt);
    \end{tikzpicture}
}

\newlength{\dividendlength}
\newlength{\divisorlength}
\newlength{\dividendheight}
\newlength{\divisorheight}
\newlength{\maxheight}

\begin{document}

\longdivision{$x^2+3x-5$}{$x-3$}

\end{document}

polynomial long division

I'm sure it could be improved upon, but I was happy enough with this (and never was happy with the paren + overline solutions).

| improve this answer | |
  • 2
    I'm going to steal this and put it in my package longdivision.sty (with reference to this post of course) unless anyone has an objection. Thanks! – Hood Chatham Oct 22 '17 at 15:24
19

\smash the right paren, so that it doesn't push up the \overline:``

\documentclass{article}
\newcommand\showdiv[1]{\overline{\smash{)}#1}}
\begin{document}
\(\showdiv{12345} \)
\end{document}

enter image description here

If you don't like the curvature of the right paren, you can squeeze it a bit (here, I squeezed it perhaps a bit too much, to 50% of its original width, just to demonstrate)

\documentclass{article}
\usepackage{scalerel}
\newcommand\showdiv[1]{\overline{\smash{\hstretch{.5}{)}}#1}}
\begin{document}
\(\showdiv{12345} \)
\end{document}

enter image description here

And if you are concerned that squeezing the glyph horizontally makes the stroke too thin, then just nearly overlay two of them:

\documentclass{article}
\usepackage{scalerel}
\newcommand\showdiv[1]{\overline{\smash{\hstretch{.5}{)}\mkern-3.2mu\hstretch{.5}{)}}#1}}
\begin{document}
\(\showdiv{12345} \)
\end{document}

enter image description here

And, to add the finishing touches:

\documentclass{article}
\usepackage{scalerel}
\usepackage{stackengine}
\usepackage{xcolor}
\newcommand\showdiv[1]{\overline{\smash{\hstretch{.5}{)}\mkern-3.2mu\hstretch{.5}{)}}#1}}
\newcommand\ph[1]{\textcolor{white}{#1}}
\begin{document}
\setstackgap{S}{1.5pt}
\stackMath\def\stackalignment{r}
\(
\stackunder{%
  5 \stackon[1pt]{\showdiv{12345}}{2469}%
}{%
  \Shortstack[l]{{\underline{10}} \ph{1}23 {\ph{1}\underline{20}} \ph{12}34 {\ph{12}\underline{30}} %
   \ph{123}45 {\ph{123}\underline{45}} \ph{1234}0}%
}
\)
\end{document}

enter image description here

| improve this answer | |
4

You can use the longdiv "package". I put package in quotes because loading it using \usepackage{} doesn't work and for whatever reason, you have to load it using \input longdiv.tex.

Then you can do long division using \longdiv{6584}{28}.

After that, you can use package polynom to do polynomial long division as \polylongdiv{x^2+2x+4}{x-1}

| improve this answer | |
1

One use case with minimal features (might need to play around with the exact numbers):

\documentclass{article}
\usepackage{graphicx}
\begin{document}
  $x+1\scalebox{1.2}{)}\hspace{-0.35em}\overline{\hspace{0.5em} x^2}$
\end{document}

enter image description here

| improve this answer | |
  • 1
    It would be nice if you make your example compilable, so people can just copy/paste to try it. – Phelype Oleinik May 20 '19 at 7:30
  • Good call. All fixed. – jackw11111 May 20 '19 at 7:42
  • 1
    Thanks :-) Note that \scalebox is provided by graphicx, so you don't need all of TikZ to use it. I edited it for you. – Phelype Oleinik May 20 '19 at 7:44
  • Yes, I didn't know why it needed tikz just that it worked. Thanks. – jackw11111 May 20 '19 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.