## WeBWorK Problems

### Long Division symbol display

by tim Payer -
Number of replies: 4
Hello,

Has anyone managed to create a clean display for a long division display in webwork?

I have experimented with a ) and \overline{} in the align conext, but it does not quite look right.

The examples I see on the web do not transfer over into webwork, so I must be missing a syntax when I paste these examples into my webwork problems.

any suggestions would be most appreciated,

Thanks, Tim

### Re: Long Division symbol display

by Alex Jordan -
All methods that I know of for doing this involve gluing two things together. Even the square root radical does that. The result can look different depending on how you are viewing it (hard copy, images, MathJax with CSS, MathJax with native MathML, etc).

You say that the examples you find online do not transfer over to WeBWorK, but can you clarify? They literally are do not compile? Or they just don't look right to you? If it's the latter, have you tried looking at it with a different output mode?

### Re: Long Division symbol display

by tim Payer -
Hi Alex,

Yes they do not compile. Here are two examples of TeX taken from the web but i am not sure if the syntax is right for webwork or what adjustment needs to be made to enable these code blocks:

Example 1:
\documentclass[border=4pt]{standalone}\usepackage{calc}\usepackage{tikz} \newcommand{\longdivision}[2]{ \settowidth{\dividendlength}{#1} \settowidth{\divisorlength}{#2} \settoheight{\dividendheight}{#1} \settoheight{\maxheight}{#1#2} \settoheight{\divisorheight}{#2} \begin{tikzpicture} [baseline=.5pt] \node at (-.5*\divisorlength-1pt,.5*\divisorheight) {#2};
\node at (.5*\dividendlength+5pt,.5*\dividendheight) {#1};
\draw [thick] (0pt,-.22*\dividendheight) arc (-70:60:\maxheight*.41 and \maxheight*.82) -- ++(\dividendlength+7pt,0pt);
\end{tikzpicture}} \newlength{\dividendlength}\newlength{\divisorlength}\newlength{\dividendheight}\newlength{\divisorheight}\newlength{\maxheight} \begin{document} \longdivision{$x^2+3x-5$}{$x-3$} \end{document}

Example 2:

\documentclass{article} \newcommand\Mydiv[2]{%$\strut#1$\kern.25em\smash{\raise.3ex\hbox{$\big)$}}$\mkern-8mu \overline{\enspace\strut#2}$} \begin{document} \Mydiv{56}{3678}\quad\Mydiv{3}{37678} \end{document}

### Re: Long Division symbol display

by Alex Jordan -
You can only do math mode LaTeX for a WeBWorK problem, not general LaTeX, which deals with text layout. That first example involves the tikz package and is out of bounds for WeBWorK.

The second example can be used though if you cut out some things.

In math mode, in your problem, put
\newcommand\Mydiv[2]{\strut#1\kern.25em\smash{\raise.3ex{\big)}}\mkern-8mu\overline{\enspace\strut#2}}
I just cut stuff until it worked. I'm not sure that every remaining component is doing what it is supposed to do.

Then you can use

in math mode in the rest of your problem.

There are two issues though. The small issue is that things like this are not going to look the same in different rendering methods. I usually see it when I zoom in and out with radicals, that the top part separates from the "checkmark".

The bigger issue is that while this will give you what you want in hard copy and MathJax output, it won't work with images. Because with images, a small tex file is made and processed into png, containing just that tiny bit of math. And with this approach, it won't see that \newcommand defining what \Mydiv means.


### Re: Long Division symbol display

by Alex Jordan -
If you use the niceTables.pl macro library, then you can do this (in PGML; change outer delimiters for TEXT). It's separated by cell entry with carriage returns just for readability. (EDIT: when I submitted this, the helpful indentation went away. Imagine it with indentation denoting when new rows in the table start.)

[@DataTable(
[
['',
'',
'',
'',
6,
5],
[[5,texpre=>'\cline{3-6}',],
6,
[3,halign=>'|c',cellcss=>'border-top:solid 1px;',],
[6,cellcss=>'border-top:solid 1px;',],
[7,cellcss=>'border-top:solid 1px;',],
[8,cellcss=>'border-top:solid 1px;',]],
['',
'',
[3,cellcss=>'border-bottom:solid 1px;',],
[3,cellcss=>'border-bottom:solid 1px;',],
[6,cellcss=>'border-bottom:solid 1px;',]],
[['',texpre=>'\cline{3-5}',],
'',
'',
3,
1,
8],
['',
'',
'',
[2,cellcss=>'border-bottom:solid 1px;',],
[8,cellcss=>'border-bottom:solid 1px;',],
[0,cellcss=>'border-bottom:solid 1px;',]],
[['',texpre=>'\cline{4-6}',],
'',
'',
'',
3,
8],
]
)@]*

It works for hard copy too, although DataTable automatically comes with a top rule and bottom rule that would be unwanted here. Perhaps I should make those optional. You could use LayoutTable, but I think positioning is important here, so LayoutTable is not appropriate.

If this doesn't work, it may be that you are on an older version of niceTables.pl or the things it relies on. I've confirmed it works for me.