# Extend vertical line in polynom division

I have this MWE

\documentclass[12pt,a4paper]{article}
\usepackage{polynom}

\begin{document}

\polylongdiv[style=D]{x^3+x^2-4}{x+2}

\end{document}


With this output

What I want is to extend the vertical line to the end of division like image below

Expanding upon Ulrike's patch to automate the process. Here, with \mypolylongdiv, the \polylongdiv is done twice for each problem, the first time to measure the drop height of the line and the 2nd time to apply it.

\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}


• External measuring is cheating ;-). The question is if one can get the value from the code. There is \pld@maxcol but depending on the polynom it is a bit to short or to long. – Ulrike Fischer Aug 24 '17 at 9:39
• @UlrikeFischer "All's fair in love and TeX" – Steven B. Segletes Aug 24 '17 at 9:40

I can make the line longer but I see no easy way to get the needed length automatically:

\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}