You can view this site in

the language of your choice.To take the quizzes, you must log in.

*Username:***student***Password:***Formulas.1**

- String TeX expressions
### String TeX expressions

# String TeX expressions

In some cases, TeX expressions must be defined as strings. These strings can be used like any other string, in functions with string arguments such as join(), pick(), etc., or for display. See this Moodle forum discussion ↗ for an example application. The discussion below shows how to define TeX expressions as strings.

**Note:**If your MathJax filter is not in compatibility mode, replace $$ with \\(.*Note the double*\\.**Warning.**If you copy TeX code directly from the pages herein, retype the following character sequences: \[, \], \(, \) and $$, that is, do not copy these sequences (because they contain a hidden character for display).## Variables in string TeX expressions

However, the numerical value of a variable can be substituted in a TeX expression defined as a string by converting the value of the variable to a string using the str() function and then joining this string with the rest of the Tex expression string.

#### Example

Substitute random numerical values for , and in the equation

then display the equation in the text field. Use the

**TeX**syntax. TeX expressions are defined as strings.Variables Random variables a={1:4}; b={4:7}; c={7:10}; Global variables p1="﹩﹩\\large{{"; p2=str(a); p3="}x^2 + {"; p4=str(b); p5="} x + {"; p6=str(c); p7="} = 0}﹩﹩"; p8=join(" ",p1,p2,p3,p4,p5,p6,p7); Main question Question text! {p8}

The Formulas question should look like this: