# Overview

LaTeX code can be used to format equations within any text box in an activity.

# LaTeX in question prompts, answers, and instructions.

Use the **Formula button **in the at the top of each text box in the activity editor to open the equation editor. Our equation editor uses LaTeX to format equations. For simple ones, you can just type, but there are lots of ways to make really good looking equations.

When you click the formula button, another window will open where you can type in your formula as well as see a preview of what it will look like. Once you're done typing in the formula, click **Update**

Found a mistake that you made after inserting the formula? No problem! Click the formula within the textbox to open up the formula editor again. Once you've made your corrections, click **Update**.

If the syntax of your LaTeX formula is wrong, you'll see red text at the bottom of the formula editor letting you know how to fix it.

# LaTeX examples

Some examples of how to use LaTeX are shown below.

`\vec`

puts a vector arrow over the next character. `\vec F`

renders as:

`\frac{a}{b}`

makes a nice a/b fraction

`a^b`

and `a_b`

make subscripts and super scripts

If you want more text in a subscript, put curly brackets around it. `F_{net}`

renders as

`\Delta`

and `\delta`

(or any greek upper or lower) will make a nice upper or lowercase delta, respectively.

use `a \cdot b`

to show multiplication instead of an `x`

.

You can mix-and-match LaTeX syntax as well! So here's how to write Newton's Second Law

`\vec a = \frac{ \Sigma \vec F}{m}`

You could also write it as:

`\vec a = \frac{ \vec F_{net}}{m}`

Here's a familiar kinematics equation:

`\Delta x = v_i t + \frac{1}{2} a t^2`

Here's an important chemical reaction:

`C_6H_{12}O_6 +6O_2 \rightarrow 6CO_2+6H_2O +\text{ATP}`

# Inserting variables within a LaTeX Expression

This requires using our robust expressions feature.

Let's assume that you've got two variables (this also works with collection variables) named `$distance`

and `$time`

. Students would be randomly assigned a value for each one, and that you want to use LaTeX to display an equation to students showing them how to calculate average speed where the equation has their *specific* values within the expression. Something like this:

The power of this feature is that what's shown to the student *is specific to the variables they were assigned!* In the example above, if a student's values were `20`

meters and `10`

seconds instead of `18`

and `3`

, respectively, that student would see `20/10`

!

Here's how you'd do it:

Click the

**Formula**buttonEnter this into the Formula text box:

`\bar{v}=\frac{\expr{$distance}}{\expr{$time}}\frac{m}{s}=\expr{$distance / $time}{\frac{m}{s}}`

There's a lot going on there, so let's break it down:

`\bar{v}`

puts the 'bar' over the`v`

.`\expr{$distance}`

and`\expr{$time}`

renders the*value*of each variable assigned to that particular student, i.e. 18 and 3, respectively.`\frac{a}{b}`

will render whatever is inside each set of curly braces as a top-over-bottom fraction. In this example,`\expr{$distance}`

and`\expr{$time}`

were used as`a`

and`b`

, resulting in the nicely formatted`8/3`

.Another

`\frac`

was used to get the units:`\frac{m}{s}`

`\expr{$distance / $time}`

didn't display`18/3`

, rather it actually*evaluated*dividing 18 by 3, resulting in the student seeing`6`

.Another

`\frac{m}{s}`

is added at the end to give units for the`6`

.

Note again that only putting a variable within the expression, such as `\expr{$distance}`

, simply displays the value of that variable. But when you use those variables in some kind of mathematical operation as in `\expr{$distance / $time}`

, that operation is evaluated and the result is displayed to the student. All kinds of different operations are available to you, not just simple division!