6

How can I write the following in LaTeX? The traditional division in LaTeX which I've not considered before.

enter image description here

Hamit
  • 191
  • 2
    You may be interested in the polynom package for generating steps similar to these automatically: http://cs.brown.edu/about/system/managed/latex/doc/polynom.pdf – Mark S. Dec 26 '15 at 21:37

1 Answers1

12

In the following example, you'll find a use of TiKZ, although a regular tabular can serve for these purposes. Don't bother yourself with the result; it uses binary arithmetic.

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{matrix, backgrounds,fit}

\begin{document}

\begin{tikzpicture}
\matrix (a) [matrix of math nodes,column sep=-1.5ex]
{
x^8 & +x^7 & +x^5 & +x^4 & & & & &x^3 & +x^2 & +1\\
x^8 & +x^7 & +x^5 &      & & & & &x^5 & +x & +1\\
    &      &    0 & x^4   \\
    &      &      & x^4  & +x^3 &  &+ x \\
    &      &      &      &  x^3 &  &+ x  \\
    &      &      &      &  x^3 & +x2 & &+ 1  \\
    &      &      &      &     & +x^2 & +x &+ 1  \\
};
\draw (a-1-9.north west)|-(a-1-11.south east);
\draw (a-2-1.south west)--(a-2-3.east|-a-2-1.south);
\draw (a-4-4.south west)--(a-4-7.east|-a-4-4.south);
\draw (a-6-5.south west)--(a-6-8.east|-a-6-5.south);
\begin{scope}[on background layer]
\node[rounded corners, inner sep=0mm,fit=(a-7-6) (a-7-8) , label={right:residu},fill=red,opacity=.5] (b) {};
\end{scope}
\end{tikzpicture}
\end{document}

M.A.R.
  • 103
Ignasi
  • 136,588