# Math Plugin

**URL:** <https://swi-prolog.discourse.group/t/math-plugin/2271>\
**Category:** General\
**Created:** [May 3, 2020, 3:58pm UTC](https://swi-prolog.discourse.group/t/math-plugin/2271 "2020-05-03T15:58:30Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [May 3, 2020, 3:58pm UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/1 "2020-05-03T15:58:30Z")

</div>

For the Math users out there I have enabled the [Discourse Math Plugin](https://meta.discourse.org/t/discourse-math-plugin/65770) which allows for the use of [MathJax](https://www.mathjax.org/) and [asciimath](http://asciimath.org/). The plug-in documentation notes that it will also do LaTeX but to what extent I don’t know.

This feature may be turned off so don’t rely on it for the the time being.

Enjoy 🙂

* * *

I am the Math plugin

I can display math inline by wrapping text with the `$` symbol like so `$E=MC^2$` which renders.

E=MC^2

I can display larger blocks of math by wrapping text in a double `$$` sign. Like so:

```prolog
$$
E=MC^2
$$

```

which renders

E=MC^2

All fonts and assets required to generate Math are embedded in the plugin.

* * *

This is a test of the asciimath ability.

This

```prolog
%
sum_(i=1)^n i^3=((n(n+1))/2)^2
%

```

renders as

sum\_(i=1)^n i^3=((n(n+1))/2)^2

---

<div class="post-metadata">

**Author:** ![joseph-vidal-rosset](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/joseph-vidal-rosset/32/2594_2.png) [@joseph-vidal-rosset](https://swi-prolog.discourse.group/u/joseph-vidal-rosset)\
**Post date:** [March 7, 2024, 5:49am UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/2 "2024-03-07T05:49:36Z")

</div>

Sorry for my very late reaction, I did not see this post.  
Does this mean that this plugin could be used with a SWI-Prolog prover inside a script for an HTML page to render directly the result? It would be a very nice thing.  
If the reply is “yes”, I would be happy to test it.

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [March 7, 2024, 7:56am UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/3 "2024-03-07T07:56:26Z")

</div>

> [@joseph-vidal-rosset](#):
>
> Does this mean that this plugin could be used with a [SWI-Prolog](https://www.swi-prolog.org/pldoc/doc_for?object=manual) prover inside a script for an HTML page to render directly the result?

No.

It is a plugin for this Discourse forum that allows math to be rendered using [MathJax](https://www.mathjax.org/) and [asciimath](http://asciimath.org/).

---

<div class="post-metadata">

**Author:** ![joseph-vidal-rosset](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/joseph-vidal-rosset/32/2594_2.png) [@joseph-vidal-rosset](https://swi-prolog.discourse.group/u/joseph-vidal-rosset)\
**Post date:** [March 7, 2024, 8:44am UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/4 "2024-03-07T08:44:41Z")

</div>

Thanks for your reply to my late intervention.  
I have understood that it is a plugin for this Discourse forum. But suppose a Mathjax script inside an html webpage, why this plugin could not be used?

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [March 7, 2024, 11:56am UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/5 "2024-03-07T11:56:06Z")

</div>

I have written something for R. It actually uses Prolog, and we currently try to make it accessible as a swipl pack.

> **[GitHub - mgondan/mathml: Translate R expressions to MathML](https://github.com/mgondan/mathml)**
>
> Translate R expressions to MathML. Contribute to mgondan/mathml development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![joseph-vidal-rosset](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/joseph-vidal-rosset/32/2594_2.png) [@joseph-vidal-rosset](https://swi-prolog.discourse.group/u/joseph-vidal-rosset)\
**Post date:** [March 7, 2024, 12:31pm UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/6 "2024-03-07T12:31:44Z")

</div>

Thanks ! It is intesting indeed. The only problem for me is that I need Mathjax to use the very useful proof.sty implemented in MathJax 3. Unfortunately, the setup to get a dynamic Mathjax is not so easy…

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [March 7, 2024, 1:00pm UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/7 "2024-03-07T13:00:58Z")

</div>

Would you mind to try it together? I would isolate the stuff we have as a swipl pack until next week, then we can check if there are missing pieces (and if you like our approach at all).

(unsure if it’s obvious: The R package can also convert expressions to MathJax, not just MathML. The MathJax ist just less elegant, because it uses “format” instead of HTML pieces.

---

<div class="post-metadata">

**Author:** ![joseph-vidal-rosset](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/joseph-vidal-rosset/32/2594_2.png) [@joseph-vidal-rosset](https://swi-prolog.discourse.group/u/joseph-vidal-rosset)\
**Post date:** [March 7, 2024, 1:19pm UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/8 "2024-03-07T13:19:51Z")

</div>

I did not know that The R package can also convert expressions to MathJax, not just MathML. I would be glad to test your work, of course. But I must be prevent you that I am very slow, I am not at all a computer scientist, my education was in philosophy and that means that I have a slow and weak brain. If you can be patient, of course, it would be nice for me to try it. 😃

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [March 7, 2024, 2:01pm UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/9 "2024-03-07T14:01:46Z")

</div>

Haha, no problem. My main concern was that you would have to wait for me because we’re too slow/busy etc.

---

<div class="post-metadata">

**Author:** ![joseph-vidal-rosset](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/joseph-vidal-rosset/32/2594_2.png) [@joseph-vidal-rosset](https://swi-prolog.discourse.group/u/joseph-vidal-rosset)\
**Post date:** [March 7, 2024, 2:05pm UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/10 "2024-03-07T14:05:29Z")

</div>

```prolog
Les packages source téléchargés sont dans
	‘/tmp/RtmphVPkBb/downloaded_packages’
Messages d'avis :
1: Dans install.packages("mathml") :
  l'installation du package ‘rswipl’ a eu un statut de sortie non nul
2: Dans install.packages("mathml") :
  l'installation du package ‘rolog’ a eu un statut de sortie non nul
3: Dans install.packages("mathml") :
  l'installation du package ‘mathml’ a eu un statut de sortie non nul
> 

Not so slow finally . I believe that all that I need to test your work is now installed. 

```

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [March 8, 2024, 7:51am UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/11 "2024-03-08T07:51:31Z")

</div>

> [@joseph-vidal-rosset](#):
>
> But suppose a Mathjax script inside an html webpage, why this plugin could not be used?

Have you seen the SWISH example that uses MathJax?

> This notebook explains using [Mathjax](https://docs.mathjax.org/) in SWISH for rendering formulas in markdown text as well as rendering query answers as formulas.

[Render mathematical formulas](https://swish.swi-prolog.org/example/render_mathjax.swinb)

---

<div class="post-metadata">

**Author:** ![joseph-vidal-rosset](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/joseph-vidal-rosset/32/2594_2.png) [@joseph-vidal-rosset](https://swi-prolog.discourse.group/u/joseph-vidal-rosset)\
**Post date:** [March 8, 2024, 8:04am UTC](https://swi-prolog.discourse.group/t/math-plugin/2271/12 "2024-03-08T08:04:13Z")

</div>

Yes, I saw this page and I am going to work on this point today and during the next week. Thanks !
