0

I'm working on emulating the polynomial long division format in Stewart's Calculus using the polynom package. In my previous research (conducted last year), I stumbled upon code that I believe was initially crafted by egreg - which serves as the foundation for my efforts - but unfortunately, I've misplaced the citation. My familiarity with this code is quite limited, and my modifications have been limited to basic kerning. I'm currently grappling with four key challenges as I try to tailor it to align with my textbook:

  1. The solution is right-shifted in the current code.
  2. The subtraction is implied in my textbook but is explicitly stated in polynom.
  3. Despite my kerning attempts, the parenthesis does not stretch low enough, noticeable upon close inspection of both images.
  4. Polynom appears to exclusively function with the variable 'x'.

I apologize if it seems like I'm asking multiple questions, it just seems to me that they are all logically connected enough to fall under one question. Any help in typesetting polynomial long division like in this textbook would be greatly appreciated.

My textbook's format:

enter image description here

My code's current format:

enter image description here

MWE:

Note: Since I don't understand this code, this may not actually be "minimal"

\documentclass{article}
\usepackage{amsmath}
\usepackage{xpatch}
\usepackage{polynom}
\makeatletter
\def\pld@ArrangeResult#1{%
    \ifx\pld@remainder\@empty
        \@tempcnta\pld@maxcol\relax
        \pld@InsertItems@do\pld@lastline
            {\pld@firsttrue\pld@PLD{\pld@R{0}{1}}}%
    \fi
    \ifnum\pld@currstage>\z@
        \pld@Extend\pld@allines{\pld@lastline\cr}%
    \else
        \pld@InsertFake\pld@lastline
    \fi
    \pld@iftopresult
        \def\pld@lastline{\pld@PrintPoly\pld@divisor\,\smash{\raisebox{2.9pt}{\big)}}\kern-3.9pt&}%
    \else
        \let\pld@lastline\@empty
        \ifx B\pld@style\else
            \def\pld@lastline{\pld@leftdelim\strut\pld@rightxdelim&}%
        \fi
    \fi
    \expandafter\pld@AR@col\expandafter\pld@PLD
                           \expandafter\pld@lastline#1+\relax+%
    \pld@SplitQuotient
    \pld@iftopresult
        \let\pld@currentline\@empty
        \expandafter\pld@AR@col\expandafter\pld@PLD
                               \expandafter\pld@currentline
                                           \pld@quotient+\relax+%
        \expandafter\pld@AR@col\expandafter\pld@XPLD
                               \expandafter\pld@currentline
                                           \pld@shadow+\relax+%
        \edef\pld@subline{%
            \noexpand\cline{\tw@-\pld@maxcol}%
            \noalign{\vskip\jot}}%
        \pld@Extend\pld@currentline{\expandafter\cr\pld@subline}%
    \else
        \@tempcnta-\@tempcnta
        \advance\@tempcnta\pld@maxcol\relax \advance\@tempcnta\@ne
        \edef\pld@span{\the\@tempcnta}%
        \ifx B\pld@style
          \pld@AddTo\pld@lastline{%
            &\multispan\pld@span${}=%
            \pld@PrintPolyWithDelims\pld@divisor
            \expandafter\pld@IfSum\expandafter{\pld@divisor}{}{\cdot}%
            \expandafter\pld@IfSum\expandafter{\pld@quotient}\pld@true
                                                             \pld@false
            \pld@if \pld@leftdelim
                    \pld@PrintPolyShadow
                    \pld@rightdelim
              \else \pld@PrintPolyShadow \fi
            \pld@firstfalse
            \expandafter\pld@PrintRemain\expandafter{\pld@remainder}$}%
        \else
          \pld@AddTo\pld@lastline{%
            &\multispan\pld@span$\pld@leftxdelim\strut\pld@rightdelim
            \pld@div
            \pld@PrintPolyWithDelims\pld@divisor=
            \pld@PrintPolyShadow
            \ifx\pld@remainder\@empty\else
                +{}%
                \setbox\z@=\hbox{$\displaystyle
                  \frac{\let\strut\@empty\pld@firsttrue \expandafter
                        \pld@PrintRemain\expandafter{\pld@remainder}}%
                       {\let\strut\@empty\pld@PrintPoly\pld@divisor}$}%
                \dp\z@=\z@\box\z@
            \fi
            $}%
        \fi
    \fi
    \expandafter\pld@AR@\pld@allines\relax}
\makeatother
\begin{document}
\polylongdiv[]{x^3+x}{x-1}
\end{document}
1

0

You must log in to answer this question.

Browse other questions tagged .