# To pass a LaTeX math constant expression to a number object

the_math-hobbyist shared this question 2 months ago

Hi.

Could I to pass a LaTeX math constant expression (v.g. "\frac{\sqrt{3}}{2^3}") to a number object? (see attacched applet).

I have tested with ParseToNumber, but it seems this command doesn't work with LaTeX expressions... (or maybe, I am missing something.)

Thanks.

What do you need it for exactly? Maybe it's better to keep it in GeoGebra syntax and then use LaTeX for display.

How's your JavaScript? You can do

ggbApplet.evalLaTeX("a= \\frac{\\sqrt{3}}{2^3}")

Note that \ needs to be \\ in JavaScript :)

2

What do you need it for exactly? Maybe it's better to keep it in GeoGebra syntax and then use LaTeX for display.

How's your JavaScript? You can do

ggbApplet.evalLaTeX("a= \\frac{\\sqrt{3}}{2^3}")

Note that \ needs to be \\ in JavaScript :)

1

Hi, Michael,

I have a multiple choice quiz. The answer options have surds. I got the options as LaTeX texts. I want to detect the possible repetition of the options. For example: Option A: 1+sqrt(3). Option B: sqrt(3)+1. (As texts, they are different). So, If I pass the LaTeX texts to numbers, I can check if I have a repetition, and make a new set of options.

I tried CAS to make the options, however, I didn't like the math look sometimes (for example, sqrt(3)·sqrt(5) in place of sqrt(15)). I tried SurdText, however sometimes, with certain values, the command didn't work (sorry, just now I couldn't to reproduce that performance to give you more details). So, I went for a way to work with texts to show the result as LaTeX expressions.

The command evalLaTeX is great. It doesn't work with GeoGebra 5 (5.0.564.0-d). However, it works very well on GeoGebra 6.