# Typesetting mathematical expressions

**URL:** <https://swi-prolog.discourse.group/t/typesetting-mathematical-expressions/1409>\
**Category:** Announce\
**Created:** [October 21, 2019, 6:27pm UTC](https://swi-prolog.discourse.group/t/typesetting-mathematical-expressions/1409 "2019-10-21T18:27:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgondan](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@mgondan](https://swi-prolog.discourse.group/u/mgondan)\
**Post date:** [October 21, 2019, 6:27pm UTC](https://swi-prolog.discourse.group/t/typesetting-mathematical-expressions/1409/1 "2019-10-21T18:27:22Z")

</div>

Dear users,

As part of my slow learning curve in Prolog, I wrote a little package that translates mathematical expressions to MathML so that they are nicely rendered on a Web browser.

Example 1.

```prolog
mathml(sin(alpha), M), html(math(M), Tokens, []).
M = mrow([mi(sin), mo(\['&ApplyFunction;']), mi(\['&alpha;'])]) ;

```

Let’s see if this renders in a pretty way:

```prolog
mathml(sin(alpha), M), html(math(M), Tokens, []), print_html(Tokens).

```

(I just copied the output here, use Firefox to see it in all it’s glory)

sin⁡α

Example 2, a bit more complicated:

```prolog
mathml(qbinom(alpha,'N',pi)=argmax(k,1,10,pbinom(k,'N',pi)=<alpha), M).

```

It is rendered like this:

QBi⁡α;Nπ=argmaxk⁡PBi⁡X≤k;Nπ≤α

[Strange that it looks terrible in Discourse although I use Firefox. I’ll find out what’s wrong here…]

So far, it is very preliminary, but I like it. I think such a thing does not exist, although I guess some people would really love it.

Best wishes,

Matthias
