generate::TeX

Generate formatted string from expressions

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

generate::TeX(e)

Description

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.

Examples

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} \,\mathrm{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[":
print(Unquoted,
      generate::TeX(new(Interval, 1, x^(a+2)))):
\left]1, x^{a + 2}\right[

Parameters

e

An arithmetical expression

Return Values

generate::TeX returns a string containing TeX code.

Overloaded By

e

Algorithms

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?