Formatting a latex fraction using variables

Hello,

I am hoping someone can shed some light on what I am doing wrong here. I am trying to use variables for the numerator and denominator of a fraction in a latex expression. I have two examples in this activity that I believe should look identical, but the one that uses variables is not formatting the negative number correctly.

I know I could create a separate variable to control the negative sign, but I’m hoping to avoid that if there is an easier fix. Any suggestions would be appreciated!

Katie

I think you need an extra set of curly braces around your variables to fix the formatting.

I’m not sure if you want this or not, but if you prefer the negative sign in front of the fraction, you can create a conditional.

num = -7
den = 4

sign = when num<0 "-" otherwise ""
absNum = numericValue("\operatorname{abs}(${num})")

content: "Find the equation of a line that passes through the point `(8, 2)` and is parallel to the line `y=${sign}\frac{${absNum}}{${den}}x+2`"
2 Likes

Ahh okay. I couldn’t get the formatting to work, but I did use the conditional approach and that is a good workaround. Thank you!