Source TeX:
\begin{array}{ll}{\phantom{-(\;}x^3+x^2-x-1}&{\left| {\underline {x - 1} } \right. }\\{\underline {- \left( {{x^3} -x^2} \right)} }&{x^2 + 2x + 1}\\\phantom{-(\;}{2x^2 -x-1}&{}\\{\underline {-\left( {2x^2 -2x} \right)}}&{}\\\phantom{-(\;}{x-1}&{}\\{\underline {-\left( {x-1} \right)}}&{} \\{\quad\quad 0}&{}\end{array}