Code and comments

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:

+ 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:

  & 2 & 8 \\
+ & 1 & 5 \\

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:


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

Subscribe to comments with RSS.

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


    July 27, 2012 at 1:46 pm

    • Good point, updated.

      Eric Wilson

      July 28, 2012 at 2:39 pm

Comments are closed.

%d bloggers like this: