I've tried to create a polynomial long division using several approaches such as the ones outlined in:
Polynomial Long Division Using Polynom
Better way to display long division?
With limited success. So I tried the naive approach which looks quite good as can be seen in the diagram, however, the vertical bar \big| is spaced too far down. If possible I'd like it to move up and ideally touch the horizontal long division bar.
How can I accomplish this?
\documentclass[12pt,a4paper]{article}
\usepackage[fleqn]{amsmath}
\usepackage[normalem]{ulem}
\begin{document}
\begin{equation*}
\begin{split}
&\uline{x^4 + \theta x^3 + \theta^2x^2 + \theta^3x + \theta^4}\\
x - \theta \ \big| & x^5 -2\\
& \uline{x^5 - \theta x^4} \\
& \theta x^4 - 2\\
& \uline{\theta x^4 - \theta^2x^3}\\
& \theta^2x^3 - 2\\
& \uline{\theta^2x^3 - \theta^3x^2}\\
& \theta^3x^2 - 2\\
&\uline{\theta^3x^2 - \theta^4x}\\
& \theta^4x - 2\\
& \uline{\theta^4x - \theta^5}\\
& \theta^5 - 2 \ \ \ \ \ \ \ \ \ = \ \ \ 0
\end{split}
\end{equation*}
\end{document}
Which produces:



