String to latex

Is there any way of converting a string (from a table cellContent) into latex?

As you would put a variable:

`${table.cellContent(1,2)}`

(that’s what I expected, but…)

Doesn’t seem to work (when the table cell is a text cell, not math cell)

Must be the inverse I’m thinking works, but I still feel like I’ve done it. Here’s a convoluted hack for you:

asLatex= parseEquation("y=${this.cellContent(1,1)}").rhs

Thanks, but I need it to work on something that’s not a well-formed expression (unpaired brackets).

You just need double quotes around the back ticks.

That seems to produce something of type string not something of type latex.

As far as I understand, latex is not a type, but just a string formatted a particular way. I could be wrong. Can you explain in more detail what you are trying to make happen?

The CL documentation says string and latex are different types:
https://teacher.desmos.com/computation-layer/documentation#types

The error message I was getting above seems consistent with that.

And the different behaviour trying join them together with the ${var1} + ${var2} sort of thing seems to support that.

The initial announcement post here also says that latex is a type CL now understands latex type!
It does say they are interchangeable, and much of the time they seem to be, but not when expanding…

Interesting. But if you change the backticks to quotes in sum1 , sum2, and sum3, they will all return 4. Sum4 will be NaN. I’m still not clear exactly what problem you are trying to solve (not being argumentative, I’m just not clear what the issue is).

1 Like

I found a work around for what I was trying to do.

I’m now just trying to understand how Desmos works in terms of types. There seems to be an actual difference between an object of type latex and a string containing latex, and some differences in what you can do with those, but no solid way of turning the latter into the former.