JohnPaul
I use `polynom`, with `\polylongdiv[style=D]` example
```
\polylongdiv[style=D]{6x^3-2x^2+x+3}{x^2-x+1}
```
![image.png](/image?hash=89446f15e9d43ad70695c47fe429d8906d884008faf71249f40ca338a679a78e)
![image.png](/image?hash=f6e0aab17459b5c7861a85c9b7c32feaad8d9e40e3fd0c56f3ad94dcd4361026)
I see [here](https://drive.google.com/file/d/1uQAovaBLxdPx0TlpsnzK4dienCt3dG3r/view) and copy this code
```
\usepackage{xpatch}
\newlength\mypolydepth
\makeatletter
\xpatchcmd\pld@ArrangeResult{\vrule height 2.25ex}{\rule{0pt}{2.2ex}\smash{\vrule height 2.25ex depth \mypolydepth}}{}{\fail}
\makeatother
\newcommand\mypolylongdiv[3][style=D]{%
\setlength\mypolydepth{0pt}%
\setbox0=\hbox{\polylongdiv[#1]{#2}{#3}}%
\setlength\mypolydepth{\dimexpr\dp0-1.3\baselineskip}%
\polylongdiv[#1]{#2}{#3}%
}
```
to get
```
\documentclass[12pt,a4paper]{article}
\usepackage{polynom}
\usepackage{xpatch}
\newlength\mypolydepth
\makeatletter
\xpatchcmd\pld@ArrangeResult{\vrule height 2.25ex}{\rule{0pt}{2.2ex}\smash{\vrule height 2.25ex depth \mypolydepth}}{}{\fail}
\makeatother
\newcommand\mypolylongdiv[3][style=D]{%
\setlength\mypolydepth{0pt}%
\setbox0=\hbox{\polylongdiv[#1]{#2}{#3}}%
\setlength\mypolydepth{\dimexpr\dp0-1.3\baselineskip}%
\polylongdiv[#1]{#2}{#3}%
}
\begin{document}
\polylongdiv[style=D]{6x^3-2x^2+x+3}{x^2-x+1}
\mypolylongdiv{x^3+x^2-4}{x+2}
\mypolylongdiv{x^4+x^2-4}{x+2}
\end{document}
```
![image.png](/image?hash=ceb5f1b5538358c1e6583f64b73caadff2400ccc0637133cd4151002d82d5379)
![image.png](/image?hash=cada770fb999e3e7845398bb7efa0aed08972c2d3f469b3c18acd47e55e85521)
I want to get the out put like [this answer](https://tex.stackexchange.com/questions/79182/how-to-draw-polynom-division/689072#689072),
```
\documentclass[border=2mm]{standalone}
\usepackage{tabularray}
\usepackage{ninecolors}
\begin{document}
\begin{tblr}{
colspec={rrrrrrrr|rrrrr},
cells={mode=dmath},
colsep = .5mm }
\SetCell[r=2]{fg=red}-
& 6x^3 & - & 2x^2 & + & x & + & 3 & x^2 & - & x & + & 1 \\
\SetHline{9-13}{blue,0.5pt}
& 6x^3 & - & 6x^2 & + & 6x & & & & & 6x & + & 4 \\
\SetHline{2-8}{blue,0.5pt}
%or \cline{2-8}
\SetCell[r=2,c=3]{fg=red}-
& & & 4x^2 & - & 5x & + & 3 & & & & & \\
& & & 4x^2 & - & 4x & + & 4 & & & & & \\
\SetHline{4-8}{blue,0.5pt}
%\cline{4-8}
& & & & - & x & - & 1 & & & & & \\
\end{tblr}
\end{document}
```
![image.png](/image?hash=0c128e9024e797f949229470a033cd17a5028146bb153ffcaa503668d9f31b1b)