Using place keepers such as #0x^2# to make alignment and calculations more straightforward.
#" "x^4+2x^3+0x^2+3x-1#
#color(magenta)(x^2)(x^2+2) ->ul(x^4+0x^3+2x^2) larr" Subtract#
#" "0 +2x^3-2x^2+3x-1#
#color(magenta)(2x)(x^2+2) ->" "ul(2x^3+0x^2+4x ) larr" Subtract"#
#" "0 -2x^2-x-1#
#color(magenta)(-2)(x^2+2)->" "ul(-2x^2+0x-4 ) larr" Subtract"#
#color(magenta)(" "0-x+3 larr" Remainder")#
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#color(magenta)(x^2+2x-2 +[(-x+3)/(x^2+2)])#
#x^2+2x-2-(x-3)/(x^2+2)#
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you are not sure about the change in sign for the bracket consider this:
Multiply by (+1) but in the form of #(-1)/(-1)#
#(-1)/(-1)[(-x+3)/(x^2+2)]#
#(-1)[(-x+3)/(-1) xx1/(x^2+2)]#
#(-1)[(+x-3) xx1/(x^2+2)]#
#-[(x-3)/(x^2+2)]" "=" "-(x-3)/(x^2+2)#