答案1
扩展 Ulrike 的补丁以自动化该过程。这里,使用\mypolylongdiv
,\polylongdiv
对每个问题执行两次,第一次测量线的下降高度,第二次应用它。
\documentclass[12pt,a4paper]{article}
\usepackage{polynom,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}
\mypolylongdiv{x^2-4}{x+2}\medskip
\mypolylongdiv{x^3+x^2-4}{x+2}\medskip
\mypolylongdiv{x^4+x^2-4}{x+2}
\end{document}
答案2
我可以让线变得更长,但是我看不出有什么简单的方法可以自动获取所需的长度:
\documentclass[12pt,a4paper]{article}
\usepackage{polynom,xpatch}
\newlength\mypolydepth
\makeatletter
\xpatchcmd\pld@ArrangeResult{\vrule height 2.25ex}{\rule{0pt}{2.2ex}\smash{\vrule height 2.25ex depth \mypolydepth}}{}{\fail}
\makeatother
\setlength\mypolydepth{6\baselineskip} %manual value
\begin{document}
\polylongdiv[style=D]{x^3+x^2-4}{x+2}
\end{document}