How do I typeset polynomial long division with multiple variables using LaTeX? I want to do polynomial long division with two and more divisors. I know there was a similar question already answered here, but the answer couldn't help since I want the long division to look like that: enter image description here

I could already solve it for when having only one divisor, but when having two it doesn't look good anymore. Can somebody help me fixing that?

This is the code I currently have:

\usepackage[utf8]{inputenc} %deutsche Umlaute
\input longdiv.tex


    q_1: x \phantom{000000000} \\[-3pt]
    q_2: -1 \phantom{00000000} \\[-3pt]
\end{array}}{x^2y-2x-y+4} \\[-3pt]  
      \underline{x^2y- \phantom{0} x \phantom{000000}} \\
      4 \\[-3pt]


This gives me this result: enter image description here I don't like the way the two divisors are taller than the bracet, but I couldn't figure out how to fix it... Thank you very much already!

  • Welcome to TeX.SE! It is good that you have provided a code example, but it would be helpful when you make the example compilable, i.e., when somebody copy-pastes the code to a new file on their own machine and runs LaTeX on it it should result in the output that you show (currently it shows an error: ! LaTeX Error: \usepackage before \documentclass.). Also, when you include an image of the output (which is helpful), then a real screenshot might be easier to read than a photo.
    – Marijn
    Aug 28, 2019 at 17:20
  • 2
    Potential duplicate: Multivariate polynomial long division using LaTeX. Aug 29, 2019 at 2:15
  • Arrays are normally centered relative to each other. Try using [t]. Aug 29, 2019 at 16:40


Your Answer

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

Browse other questions tagged or ask your own question.