1

Problem:

Trying to locally typeset a polynomial division problem by using the package polynomial.

Minimal Working Example (MWE):

\documentclass[a4paper,11pt]{book}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}

\[
  \begin{array}{l|l}
    & 4x - 2 = K(x) \\ \cline{2-2} 
    N(x) = 2x^2 + x - 4 & 8x^3 + 0x^2 - 2x + 3 = T(x) \\ \cline{1-1}
    & -(8x^3 + 4x^2 - 16x) \\ \cline{2-2}
    & -4x^2 + 14x + 3 \\
    & -(-4x^2 - 2x + 8) \\ \cline{2-2}
    & 16x - 5 = R(x)

  \end{array}
\]
\end{document}

Current output:

enter image description here

Desired output:

enter image description here

The polynominal should:

  1. Be left-aligned as a whole
  2. First part on the right (left aligned), second part (center aligned) and third part (right aligned)
  3. Allow for text on each row on the right
  4. Only have vertical line for the second row
  • What does "first part", "second part" and "third part" in 2. refer to? – leandriis Jul 7 at 10:05
  • @leandriis Sorry for not clarifying it, first part (8x + 0x - 2x ...), second part (-4x + 14x ...) and third (16x - 5 ...). It's basically the three sections below the first row on the right. – kexxcream Jul 7 at 10:07
  • Is there a reason why you don't want to use a package designated to typesetting polynomial divisions? – leandriis Jul 7 at 13:52
  • @leandriis Considering that I have not been able to solve the adjustments, I would like to kindly ask to give the package polynomial a chance. How would a possible solution look? – kexxcream Jul 7 at 14:11
1

With a tabular environment and some \multicolumn commands:

enter image description here

(Red lines indicate the textwidth and won't show up in your real document.)

\documentclass[a4paper,11pt]{book}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{array}

\begin{document}

\noindent 
{\renewcommand{\arraystretch}{1.25}
\begin{tabular}{>{$}l<{$}>{$}l<{$}l}
                                             & \phantom{-(} 4x - 2 = K(x)                                      \\ \cline{2-2} 
  \multicolumn{1}{l|}{$N(x) = 2x^2 + x - 4$} & \phantom{-(}8x^3 + 0x^2 - 2x + 3 = T(x)                         \\ \cline{1-1}
                                             & -(8x^3 + 4x^2 - 16x)                                            \\ \cline{2-2}
                                             & \multicolumn{1}{c}{$\phantom{-(}-4x^2 + 14x + 3$}  & some text  \\
                                             & \multicolumn{1}{c}{$-(-4x^2 - 2x + 8)$}                         \\ \cline{2-2}
                                             & \multicolumn{1}{r}{$16x - 5 = R(x)$}               & some text
\end{tabular}}

\end{document}

With some more \phantom commands one can get the desired layout that was requested in the comments:

enter image description here

\documentclass{article}
\usepackage{array}

\begin{document}
{\renewcommand{\arraystretch}{1.25}
\begin{tabular}{>{$}l<{$}>{$}l<{$}l}
                                             & \phantom{-(} 4x - 2 = K(x)                                      \\ \cline{2-2} 
  \multicolumn{1}{l|}{$N(x) = 2x^2 + x - 4$} & \phantom{-(}8x^3 + 0x^2 - \phantom{1}2x + 3 = T(x)                         \\ \cline{1-1}
                                             & -(8x^3 + 4x^2 - 16x)                                            \\ \cline{2-2}
                                             & \phantom{-(8x^3}-4x^2 + 14x + 3  & some text  \\
                                             & \phantom{8x^3}-(-4x^2 - \phantom{1}2x + 8)                         \\ \cline{2-2}
                                             & \multicolumn{1}{r}{$16x - 5 = R(x)$}               & some text
\end{tabular}}
\end{document}
  • Thanks, is there a possibility to align the 4x^2 with each other and the 14x/-2x/16x with each other? – kexxcream Jul 7 at 11:39
  • @kexxcream: This is most likely possible. However, it will either require manual adjustment or the usage of a tabular with a total of 7 columns. – leandriis Jul 7 at 11:56
  • How would I go about for manual adjustment? Could you provide an example? – kexxcream Jul 7 at 12:32
  • 1
    @kexxcream: I have found a solution using some more \phantom commands. I have accordingly updated my answer. Hope this suggestion suits your needs. – leandriis Jul 7 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.