Doubts about how to use LaTex combined with object values and if statement

Cecilia Lucía Gigena shared this question 1 year ago
Answered

I am trying to redefine text "texto4" so that this happens:

•if b value=0 or b value>0, it has to show the formula like this: y=an/ad x + b

(and use LaTex Fraction options)

•if b value<0, show formula like this: y=an/ad x b

I want that because, otherwise, formula will be like: y=2/3+-1

(negative numbers already show -, I want to ommit the +).


I am typnig this:

texto4=Si(b<0,LaTex("\frac{"an"}{"ad"}"+"x"+"b",true,true,true),LaTex("\frac{"an"}{"ad"}"+"x"+"+"+"b",true,true,true))


but it shows an error. I assume it is a syntax problem.


I provide a dropbox link in case you cannot read my attachment: https://www.dropbox.com/s/b...

Comments (1)

photo
1

Try


texto4=If(b<0,FormulaText("\frac{"an"}{"ad"}"+"x"+"b",true),FormulaText("\frac{"an"}{"ad"}"+"x"+"+"+"b",true))  

or even better

texto4=FormulaText(If(b<0,"\frac{"an"}{"ad"}"+"x"+"b","\frac{"an"}{"ad"}"+"x"+"+"+"b"),true) 

© 2022 International GeoGebra Institute