Practical and theoretical aspects of software development

## 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
----


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 eXtra Large OPerator 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.

Written by Eric Wilson

September 19, 2011 at 12:29 pm

Posted in how-to

Tagged with ,

### 2 Responses

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

Jason

July 27, 2012 at 1:46 pm

• Good point, updated.

Eric Wilson

July 28, 2012 at 2:39 pm