# String to latex

**URL:** https://cl.desmos.com/t/string-to-latex/4189
**Category:** Questions
**Created:** [March 26, 2022, 10:06pm UTC](https://cl.desmos.com/t/string-to-latex/4189 "2022-03-26T22:06:19Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![SeanMaths4EAL](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/seanmaths4eal/32/289_2.png) [@SeanMaths4EAL](https://cl.desmos.com/u/SeanMaths4EAL)
#### Post date: [March 26, 2022, 10:06pm UTC](https://cl.desmos.com/t/string-to-latex/4189/1 "2022-03-26T22:06:19Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)
#### Post date: [March 27, 2022, 1:14am UTC](https://cl.desmos.com/t/string-to-latex/4189/2 "2022-03-27T01:14:06Z")

</div>

As you would put a variable:

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

```

---

<div class="post-metadata">

### Author: ![SeanMaths4EAL](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/seanmaths4eal/32/289_2.png) [@SeanMaths4EAL](https://cl.desmos.com/u/SeanMaths4EAL)
#### Post date: [March 27, 2022, 1:18am UTC](https://cl.desmos.com/t/string-to-latex/4189/3 "2022-03-27T01:18:38Z")

</div>

(that’s what I expected, but…)

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

 ![CleanShot 2022-03-27 at 12.18.04@2x](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/f/fdb45939bee9fa38290122f87aa254304db27b60.png)

---

<div class="post-metadata">

### Author: ![SeanMaths4EAL](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/seanmaths4eal/32/289_2.png) [@SeanMaths4EAL](https://cl.desmos.com/u/SeanMaths4EAL)
#### Post date: [March 27, 2022, 1:20am UTC](https://cl.desmos.com/t/string-to-latex/4189/4 "2022-03-27T01:20:15Z")

</div>

> **[Test • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/623fbaa14e18884f39058883)**
>
> by Sean Kelleher

---

<div class="post-metadata">

### Author: ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)
#### Post date: [March 27, 2022, 1:35am UTC](https://cl.desmos.com/t/string-to-latex/4189/5 "2022-03-27T01:35:46Z")

</div>

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

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

```

---

<div class="post-metadata">

### Author: ![SeanMaths4EAL](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/seanmaths4eal/32/289_2.png) [@SeanMaths4EAL](https://cl.desmos.com/u/SeanMaths4EAL)
#### Post date: [March 27, 2022, 2:39am UTC](https://cl.desmos.com/t/string-to-latex/4189/6 "2022-03-27T02:39:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)
#### Post date: [March 27, 2022, 2:58am UTC](https://cl.desmos.com/t/string-to-latex/4189/7 "2022-03-27T02:58:51Z")

</div>

You just need double quotes around the back ticks.

> **[\[Copy of\] Test • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/623fd2833e0f161be54e8a15)**
>
> by Daniel Wekselgreene

---

<div class="post-metadata">

### Author: ![SeanMaths4EAL](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/seanmaths4eal/32/289_2.png) [@SeanMaths4EAL](https://cl.desmos.com/u/SeanMaths4EAL)
#### Post date: [March 27, 2022, 3:14am UTC](https://cl.desmos.com/t/string-to-latex/4189/8 "2022-03-27T03:14:08Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)
#### Post date: [March 27, 2022, 4:25am UTC](https://cl.desmos.com/t/string-to-latex/4189/9 "2022-03-27T04:25:32Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![SeanMaths4EAL](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/seanmaths4eal/32/289_2.png) [@SeanMaths4EAL](https://cl.desmos.com/u/SeanMaths4EAL)
#### Post date: [March 27, 2022, 5:23am UTC](https://cl.desmos.com/t/string-to-latex/4189/10 "2022-03-27T05:23:51Z")

</div>

The CL documentation says string and latex are different types:  
[https://teacher.desmos.com/computation-layer/documentation#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.

---

<div class="post-metadata">

### Author: ![SeanMaths4EAL](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/seanmaths4eal/32/289_2.png) [@SeanMaths4EAL](https://cl.desmos.com/u/SeanMaths4EAL)
#### Post date: [March 27, 2022, 5:31am UTC](https://cl.desmos.com/t/string-to-latex/4189/11 "2022-03-27T05:31:47Z")

</div>

![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/c/c1ef67d76d85370a37a58f096d55e04e3235750a.jpeg)

---

<div class="post-metadata">

### Author: ![SeanMaths4EAL](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/seanmaths4eal/32/289_2.png) [@SeanMaths4EAL](https://cl.desmos.com/u/SeanMaths4EAL)
#### Post date: [March 27, 2022, 5:34am UTC](https://cl.desmos.com/t/string-to-latex/4189/12 "2022-03-27T05:34:28Z")

</div>

The initial announcement post here also says that latex is a type [CL now understands latex type!](https://cl.desmos.com/t/cl-now-understands-latex-type/1429)  
It does say they are interchangeable, and much of the time they seem to be, but not when expanding…

---

<div class="post-metadata">

### Author: ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)
#### Post date: [March 27, 2022, 7:41pm UTC](https://cl.desmos.com/t/string-to-latex/4189/13 "2022-03-27T19:41:21Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![SeanMaths4EAL](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/seanmaths4eal/32/289_2.png) [@SeanMaths4EAL](https://cl.desmos.com/u/SeanMaths4EAL)
#### Post date: [April 3, 2022, 8:17pm UTC](https://cl.desmos.com/t/string-to-latex/4189/14 "2022-04-03T20:17:35Z")

</div>

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.
