Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to type a paper for a teacher, who hasn't seen the European division method, so that she could possibly use it in her curriculum.

I need something to look like this

x^2+4x+4       Box(x+2) 
-(x^2 + 2x)
----------------
2x+4 
-(2x + 4)
-----------------
0
share|improve this question
    
Welcome to TeX.SE. –  Peter Grill Nov 9 '12 at 1:38
    
I am not sure what the Box(x+2) means. –  Peter Grill Nov 9 '12 at 1:45
2  
“European division” is unknown to me. I guess you meant en.wikipedia.org/wiki/Polynomial_long_division –  Speravir Nov 9 '12 at 2:28
1  
Great picture IMHO: commons.wikimedia.org/wiki/File:Beispiel_Polynomdivision.png –  Speravir Nov 9 '12 at 2:49
1  
Did you perchance mix up the words "European" and "Euclidean"? –  Federico Poloni Nov 10 '12 at 10:04
show 1 more comment

2 Answers

up vote 8 down vote accepted

Here is one way to do this:

enter image description here

Notes:

  • The booktabs package was used to provide flexible horizontal rules.
  • The \Ph macro uses \hphantom{)} to insert a horizontal space equivalent to the closing bracket to get things all aligned.

Code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{array}
\newcommand*{\Ph}{\hphantom{)}}%
\begin{document}
$\begin{array}{r@{} r@{} r r}
  x^2 &{}+4x\Ph&{}+4\Ph       &\fbox{$(x+2)$} \\
-(x^2 &{}+ 2x) &\\
\cmidrule{1-2}
      & 2x\Ph &{}+4\Ph\\
      &-(2x\Ph &{}+4) \\
\cmidrule{2-3}
      & &0\Ph
\end{array}$
\end{document}
share|improve this answer
    
Thanks but how do I get an actual box for the x+2? I really appreciate your help. My gratitude. –  Person Nov 9 '12 at 1:46
    
@Person: Use \boxed{($x+2$)} with amsmath loaded. –  Harish Kumar Nov 9 '12 at 1:48
    
@HarishKumar: I was not aware of \boxed, but that seems to force the text inside the box to be in \text mode somehow even with $ $, so used \fbox instead. –  Peter Grill Nov 9 '12 at 1:53
    
@PeterGrill: \boxed is defined by amsmath for mathmode. There is a similar \Aboxed in mathtools. If you use \boxed{(x+2)}, then it will be in mathmode. Don't use $. –  Harish Kumar Nov 9 '12 at 2:17
    
@HarishKumar: Thanks. I am familiar with \Aboxed form my very first question posted on TeX.SE. But, am surprised that \boxed{$(x+2)$} compiled with x in text mode -- seems like a bug? –  Peter Grill Nov 9 '12 at 2:43
add comment

Try looking at the package polynom.sty (CTAN, TeXdoc). It can even do the division for you.

share|improve this answer
3  
For an example, see tex.stackexchange.com/a/79222/586 –  Torbjørn T. Nov 10 '12 at 8:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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