This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Generate formatted string from expressions

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.




generate::TeX(e) returns a TeX formatted string representing e. This string may be printed to a file using fprint. Use the printing option Unquoted to remove quotes and to expand special characters like newlines and tabs.

The output string may be used in the math-mode of TeX. Note that generate::TeX doesn't break large formulas into smaller ones.


Example 1

generate::TeX generates a string containing the TeX code:

generate::TeX(hold(int)(exp(x^2)/x, x))

Use print with option Unquoted to get a more readable output:

print(Unquoted, generate::TeX(hold(int)(exp(x^2)/x, x)))
\int \frac{\mathrm{e}^{x^2}}{x} \,d x

Example 2

This example shows how to write a "TeX"-method for a domain. The domain elements represent open intervals. The "TeX"-method makes recursive use of generate::TeX in order to TeX-format its operands and concatenates the resulting strings to a new string containing the TeX output of the interval.

Interval := newDomain("Interval"):
Interval::TeX :=
  e -> "\\left]".generate::TeX(extop(e, 1)).
       ", ".generate::TeX(extop(e, 2))."\\right[":
      generate::TeX(new(Interval, 1, x^(a+2)))):
\left]1, x^{a + 2}\right[



An arithmetical expression

Return Values

generate::TeX returns a string containing TeX code.

Overloaded By



The TeX packages amsmath and amssymb are needed.

A domain overloading generate::TeX has to provide a function as its "TeX"-slot which translates its elements into a TeX formatted string. This function may use generate::TeX recursively. See Example 2.

See Also

MuPAD Functions

Was this topic helpful?