## Typesetting vertical arithmetic in LaTeX using `xlop`

If the question involves mathematical typesetting, then you can be sure that the answer is LaTeX. But if you are off the beaten path, LaTeX can be both the solution and a new problem.

I was interested in typesetting some elementary-school style vertical arithmetic problems. You know, like:

28 + 15 ----

Except with better readability.

This can be done by hand, using some sort of array, but this introduces various types of pain, which could result in something like:

\begin{tabular}{ccc} & 2 & 8 \\ + & 1 & 5 \\ \hline \end{tabular}

Ugly. Numbers need to be split into their digits, and different sizes of numbers require different sizes of arrays.

What to do? Not surprisingly, the solution is out there, and it solves problems I wasn’t even yet aware of. Just include the `xlop`

package, and the above reduces to:

\opadd{28}{15}

…almost. The e**X**tra **L**arge **OP**erator package includes the answer by default, and any digits that are carried in the operation. The easiest way to eliminate them that I found was to set a `resultstyle`

and `carrystyle`

that would make them invisible.

It’s a shame to not include some pretty typesetting in this post, but it seems that there is no obvious way to get MathJax,`xlop`

, and WordPress.com to work together. Rather than shave that yak, I thought I would briefly mention that if you are looking for something like `xlop`

, then good news, it’s out there, and it’s easy to use.

This would be a much handier post with a snippet of how you made the answers invisible…

JasonJuly 27, 2012 at 1:46 pm

Good point, updated.

Eric WilsonJuly 28, 2012 at 2:39 pm