I think that the way I lay out the diagram for long division is different from that. If it's any help, here is an example of the code that I used some years ago when teaching a class how to do long division of polynomials. The code is

Code:

\begin{array}{r@{}rrrrl}
&&x^2&+7x&+10\\
\cline{2-5}
x-3\;|&\;x^3 &+ 4x^2& - 11x& - 25 \\
&x^3&-3x^2 \\
\cline{2-3}
&&7x^2&-11x \\
&&7x^2&-21x \\
\cline{3-4}
&&&10x&-25 \\
&&&10x&-30&\quad\mbox{The quotient is }x^2+7x+10. \\
\cline{4-5}
&&&&5&\quad\mbox{The remainder is }5.
\end{array}

It produces this:

$\displaystyle \begin{array}{r@{}rrrrl}

&&x^2&+7x&+10\\

\cline{2-5}

x-3\;|&\;x^3 &+ 4x^2& - 11x& - 25 \\

&x^3&-3x^2 \\

\cline{2-3}

&&7x^2&-11x \\

&&7x^2&-21x \\

\cline{3-4}

&&&10x&-25 \\

&&&10x&-30&\quad\mbox{The quotient is }x^2+7x+10. \\

\cline{4-5}

&&&&5&\quad\mbox{The remainder is }5.

\end{array}$

A simpler version for dividing 12 by 5 would look like this:

Code:

\begin{array}{r@{}r@{}r@{}}
&&2\\
\cline{2-3}
5\;|&\;1&2 \\
&1&0 \\
\cline{2-3}
&&2 \\
\end{array}

It gives this: $\displaystyle \begin{array}{r@{}r@{}r@{}}

&&2\\

\cline{2-3}

5\;|&\;1&2 \\

&1&0 \\

\cline{2-3}

&&2 \\

\end{array}

$