如何在背面写长除法?

How to write long division in overleaf?

\usepackage{scalerel,mathtools}
\setcounter{MaxMatrixCols}{20}    
\usepackage{graphicx,multirow,pgffor}
\usepackage{hyperref}
\newcommand{\PhantC}{\phantom{\colon}}
\newcommand{\CenterInCol}[1]{\multicolumn{1}{c}{#1}}
\newcommand{\longdiv}{\smash{\mkern-0.43mu\vstretch{1.5}{\hstretch{.7}{|}}}}

\begin{document}

\[
\arraycolsep=6pt
\renewcommand\arraystretch{1.2}

\begin{array}{l@{\hskip\arraycolsep}l@{\hskip\arraycolsep}r}
 & & a_1= y_2x_4 - y_3x_1^2 + y_3x_4^2 - y_4x_1^3 + y_4x_4^3 \
 & & a_2=-y_2x_4 - y_3x_4^2 - y_4x_4^3 \ 
\cline{2-3}
 y_1+y_2x_4+y_3x_4^2+y_4x_4^3 & \longdiv & y_1y_2x_4 - y_1y_3x_1^2 +    
 y_1y_3x_4^2 - y_1y_4x_1^3 + y_1y_4x_4^3 + y_2^2x_1x_4 + 
 y_2y_3x_1x_4^2 + y_2y_4x_1x_4^3\

-y_2x_1+y_2x_4-y_3x_1^2+y_3x_4^2-y_4x_1^3+y_4x_4^3 & \longdiv &





\end{array}
\]

\end{document}

我需要一些帮助来编写这个长除法,因为它即将超出页面。

我在 latex 中编写长除法时遇到的问题是当除数和被除数是 3 行长时 polynomials.In 在这些情况下我的多项式超出了页面。

你可以把被除数写成两行,就像你写除数一样。 以下内容应该保留在您页面的边缘:

\[
\arraycolsep=6pt
\renewcommand\arraystretch{1.2}
\begin{array}{l@{\hskip\arraycolsep}l@{\hskip\arraycolsep}r}
& & a_1= y_2x_4 - y_3x_1^2 + y_3x_4^2 - y_4x_1^3 + y_4x_4^3 \
& & a_2=-y_2x_4 - y_3x_4^2 - y_4x_4^3 \ 
\cline{2-3}
y_1+y_2x_4+y_3x_4^2+y_4x_4^3-y_2x_1
& \longdiv & y_1y_2x_4 - y_1y_3x_1^2 + y_1y_3x_4^2 - y_1y_4x_1^3 + y_1y_4x_4^3 \
+y_2x_4-y_3x_1^2+y_3x_4^2-y_4x_1^3+y_4x_4^3
& \longdiv & + y_2^2x_1x_4 + y_2y_3x_1x_4^2 + y_2y_4x_1x_4^3
\end{array}
\]

这适用于标准 1 英寸边距的 US 信纸和 2.5 厘米边距的 A4 纸上的 12pt 字体。