Use mathjax to take inputs to formula in LaTeX form.

110 views
Skip to first unread message

Swapneel Shah

unread,
Nov 5, 2023, 11:01:49 PM11/5/23
to MathJax Users
Dear community,

We have integrated Mathjax (Asciimath) in our website https://www.calculatoratoz.com/. And it works great!

We are now looking to use Mathjax to take user Inputs from user in LaTeX form. As in we want to show the formula in LaTeX form and replace variables with HTML Textboxes. So that users can add input in textboxes and we can evaluate the formula and calculate the output.

For Example-
Currently, we are taking input to the formula in linear fashion-
Screenshot 2023-11-06 092331.png
We believe that if we can take input in LaTeX form it would be more intuitive for the user.
Screenshot 2023-11-06 092535.png
In other words, we would like to replace the "r" and "h" above with a textbox and take inputs in LaTeX form.

Can MathJax be of help here? Any other pointers would also help.

Thank you,
Swapneel Shah

Davide Cervone

unread,
Nov 7, 2023, 10:17:26 AM11/7/23
to mathja...@googlegroups.com
You don't say which version of MathJax you are using.  The upcoming v4 (now out in beta release) allows embedding HTML in TeX and MathML.  See


for details.  For versions 2 and 3, there are third-party extensions that allow input boxes within the expressions.  For example, this issue


gives code that implements such a textbox for v3, and a version for v2 is at


Perhaps one of those will do what you need.

Davide

On Nov 5, 2023, at 11:01 PM, Swapneel Shah <swap...@gmail.com> wrote:

Dear community,

We have integrated Mathjax (Asciimath) in our website https://www.calculatoratoz.com/. And it works great!

We are now looking to use Mathjax to take user Inputs from user in LaTeX form. As in we want to show the formula in LaTeX form and replace variables with HTML Textboxes. So that users can add input in textboxes and we can evaluate the formula and calculate the output.

For Example-
Currently, we are taking input to the formula in linear fashion-
<Screenshot 2023-11-06 092331.png>
We believe that if we can take input in LaTeX form it would be more intuitive for the user.
<Screenshot 2023-11-06 092535.png>
In other words, we would like to replace the "r" and "h" above with a textbox and take inputs in LaTeX form.

Can MathJax be of help here? Any other pointers would also help.

Thank you,
Swapneel Shah

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/2c9e013b-434e-4606-9489-9afb7a837211n%40googlegroups.com.
<Screenshot 2023-11-06 092535.png><Screenshot 2023-11-06 092331.png>

Message has been deleted

Alžběta Kašparová

unread,
Nov 7, 2023, 12:11:03 PM11/7/23
to mathja...@googlegroups.com
Heslo, I use MathJax-Latex version 1.3.12. on my website. 

út 7. 11. 2023 v 16:17 odesílatel Davide Cervone <dpv...@gmail.com> napsal:

Davide Cervone

unread,
Nov 7, 2023, 2:46:30 PM11/7/23
to mathja...@googlegroups.com
That's the version of the MathJax-LaTeX plugin (for WordPress I presume), not the version of MathJax that that plugin uses.  From the plugin release notes, it seems to be using v2.7.9, so you would need to use the legacy plugin from the last link below.  The WordPress plugin seems to give you the ability to change the MathJax configuration (I do use WordPress myself, so can't check this), so you should be able to make the needed changes there to include the needed third-party extension.  See


for information about how the configuration should be made.  You probably ned to use the second method, and depending on how the WordPress plugin specifies the configuration, you may be able to just add

AuthorInit: function () {            
  MathJax.Ajax.config.path["Contrib"] = "https://cdn.jsdelivr.net/gh/mathjax/MathJax-third-party-extensions/legacy";
        },
  extensions: ['[Contrib]/forminput/forminput.js']

to the existing configuration (if there is already an extensions array, add the forminput.js file into that rather than add a second extensions array).

Whether this works depends on how the MathJax-LaTeX plugin handles your custom configuration.  I haven't looked into the code to see how that is done.  You may need to contact the maintainer of that plugin in order to find out how to include this into the configuration.

Davide


On Nov 7, 2023, at 10:44 AM, Alžběta Kašparová <kasparov...@gmail.com> wrote:

Heslo, I jsem MathJax-Latex version 1.3.12. 

úterý 7. listopadu 2023 Davide Cervone <dpv...@gmail.com> napsal(a):
You don't say which version of MathJax you are using.  The upcoming v4 (now out in beta release) allows embedding HTML in TeX and MathML.  See


for details.  For versions 2 and 3, there are third-party extensions that allow input boxes within the expressions.  For example, this issue


gives code that implements such a textbox for v3, and a version for v2 is at


Perhaps one of those will do what you need.

Davide
On Nov 5, 2023, at 11:01 PM, Swapneel Shah <swap...@gmail.com> wrote:

Dear community,

We have integrated Mathjax (Asciimath) in our website https://www.calculatoratoz.com/. And it works great!

We are now looking to use Mathjax to take user Inputs from user in LaTeX form. As in we want to show the formula in LaTeX form and replace variables with HTML Textboxes. So that users can add input in textboxes and we can evaluate the formula and calculate the output.

For Example-
Currently, we are taking input to the formula in linear fashion-
<Screenshot 2023-11-06 092331.png>
We believe that if we can take input in LaTeX form it would be more intuitive for the user.
<Screenshot 2023-11-06 092535.png>
In other words, we would like to replace the "r" and "h" above with a textbox and take inputs in LaTeX form.

Can MathJax be of help here? Any other pointers would also help.

Thank you,
Swapneel Shah

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-users+unsubscribe@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/2c9e013b-434e-4606-9489-9afb7a837211n%40googlegroups.com.
<Screenshot 2023-11-06 092535.png><Screenshot 2023-11-06 092331.png>
--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/50F15A6C-D5D2-4302-A240-36D2FD3D2F76%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.

Swapneel Shah

unread,
Nov 7, 2023, 9:25:17 PM11/7/23
to MathJax Users
Dear Davide Cervone,

We are using Asciimath version -

v4 Looks promising... We will explore the HTML embedding option in v4 and get back. Thank you for pointing  us to this.

Regards,

Davide Cervone

unread,
Nov 8, 2023, 3:23:07 PM11/8/23
to mathja...@googlegroups.com
There is no mechanism for embedding HTML expressions within mathematics specified in AsciiMath notation.  It is only available for expressions in TeX and MathML formats.

Davide


Swapneel Shah

unread,
Nov 8, 2023, 8:03:27 PM11/8/23
to MathJax Users
Yeah, we also came to same conclusion. However, as a workaround we could successfully use the "MathML Code" and then embedded textboxes into that code. This way we could not just add Textboxes, but we could do much more (html formatting, add JavaScript, etc).

Screenshot 2023-11-09 061810.png

So the next Question for the community, is there an API/ some recommended process to get LaTeX 'MathML Code' from  AsciiMath  notation?
(Not sure if I should be opening a new discussion for this).

Awaiting your kind guidance.

Regards,

Davide Cervone

unread,
Nov 9, 2023, 1:59:03 PM11/9/23
to mathja...@googlegroups.com
So the next Question for the community, is there an API/ some recommended process to get LaTeX 'MathML Code' from  AsciiMath  notation?
(Not sure if I should be opening a new discussion for this).

It looks like you are using MathJax v2, so the options are more limited, there.  Assuming you want to do this server-side, there is the old mathjax-node npm project that was a hack to allow MathJax to be run server-side on the command line.

But it would be better to use MathJax v3, which was redesigned to allow it to be used directly in node applications server side.  See, for example, the am2mml command-line program in the MathJax node demos repository.  

Perhaps one of these will be what you are looking for.

Davide
Reply all
Reply to author
Forward
0 new messages