render vertically lay out addition of two numbers with MathJax and asciimath on browser

372 Views Asked by At

I would like to render two numbers on a web page like this:

    123
  + 456
 ______

There is a similar question using mathml and mathjax Unable to render vertically lay out addition of two numbers with MathJax and MathML

Is there a way to achieve such rendering using asciimath

1

There are 1 best solutions below

0
On

AsciiMath does not really have a syntax to do this properly, but you could try

{:(\ \ \ \ 123),(+\ 456),(_):}

The problem is that you have to do the alignment to the right by hand using \ (backslash space), which is hard to get right. It would be better to use TeX or MathML input for this. Note that you can configure MathJax to allow for more than one input form, so could use AsciiMath for everything else, and MathML for this. For example

<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
<mtable columnalign="right">
  <mtr><mtd><mn>123</mn></mtd></mtr>
  <mtr><mtd><mo form="infix">+</mo><mn>456</mn></mtd></mtr>
  <mtr><mtd><mo stretchy="true">-</mo></mtd></mtr>
</mtable>
</math>

would produce the aignment that you are looking for.