generate::TeX -- generate TeX
formatted string from expressions
Introductiongenerate::TeX(e) generates TeX output for
an expression e.
Call(s)generate::TeX(e)
Parameterse |
- | an arithmetical expression |
Returnsgenerate::TeX returns a string containing TeX code.
e
Related
Functions
Detailsgenerate::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.generate::TeX doesn't break large formulas into smaller
ones.
Example
1generate::TeX generates a string containing
the TeX code:
>> generate::TeX(hold(int)(exp(x^2)/x, x))
"\\int \\frac{\\mbox{exp}\\left(x^2\\right)}{x} d 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{\mbox{exp}\left(x^2\right)}{x} d x
Example
2This 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[
Backgroundgenerate::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. Cf. example 2.