# TexFormat¶

TexFormat provides a coercion from OutputForm to TeX format. The particular dialect of TeX used is LaTeX, but for flexibility reasons TexFormat outputs everything into a fricasmath environment in which certain additional commands are avaiblable. These commands are defined in a .sty file that is distributed with the source code of FriCAS.

altsupersub: (String, Integer) -> (Integer, List OutputForm) -> List String
altsupersub(cmd, p) returns a handler such that altsupersub(cmd, p)(prec, args) formats the first argument with respect to the precedence p. The remaining arguments are formatted without parentheses and interpreted as subscript, superscript, subscript, superscript, etc. where the subscripts and superscripts are pairwise aligned. Outer parentheses are added if p < prec.
binary2: (String, Integer, Integer, Integer) -> (Integer, List OutputForm) -> List String
binary2(cmd, p, p1, p2) returns a handler such that binary2(cmd, p, p1, p2)(prec, args) formats args.1 and args.2 according to the precedences p1 and p2, respectively. It puts the result into the first and second argument of the TeX command given by cmd. Outer parentheses are added if p < prec.
binary: (String, Integer) -> (Integer, List OutputForm) -> List String
binary(cmd, p) is identical to binary2(cmd, p, p, p.
binaryNoParen: String -> (Integer, List OutputForm) -> List String
binaryNoParen(cmd) returns a handler such that binaryNoParen(cmd)(prec, args) formats args.1 and args.2 without outer parentheses and puts the result into the first and second argument of the TeX command given by cmd.
coerce: % -> OutputForm
from CoercibleTo OutputForm
coerce: OutputForm -> %
coerce(o) changes o in the standard output format to TeX format.
convert: (OutputForm, Integer) -> %
from OutputFormatterCategory
display: % -> Void
from OutputFormatterCategory
display: (%, Integer) -> Void
display(t, width) outputs the TeX formatted code t so that each line has length less than or equal to spadvar{width}.
environment: (String, String, String) -> (Integer, List OutputForm) -> List String
environmnt(env, x, sep) returns a handler that typesets its arguments (without parentheses) in a LaTeX environment with name env. The string x is put right after the start of the environment. The arguments are separated by the string sep.
epilogue: % -> List String
epilogue(t) extracts the epilogue section of a TeX form t.
format: % -> List String
format(t) extracts the TeX section of a TeX form t.
formatExpression: (OutputForm, Integer) -> List String
formatExpression(o, p) returns a list of strings that represent the expression o in TeX format when considered in a context with outer precedence p. This function is the main dispatcher function. It first checks whether o is an integer or a string and treats these cases. Then, if the number $n$ of arguments is less than 3, it tries to find a handler for ths top-level operator of o. If none is found, it checks for a handler of an n-ary operator. If no handler is found, the operator is treated as a function symbol and formatted as such.
matrix: (String, String) -> (Integer, List OutputForm) -> List String
matrix(env, sep) returns a handler that typesets a matrix in a LaTeX environment with name env that takes one argument. The argument to this environment is the number of columns of the matrix. The rows are separated by the string sep.
nary: (String, Integer) -> (Integer, List OutputForm) -> List String
nary(sep, p) returns a handler such that nary(sep, p)(prec, args) formats the arguments according to the precedence p. These arguments will be separated by the string sep. Outer parentheses are added if p < prec.
naryNoParen: String -> (Integer, List OutputForm) -> List String
naryNoParen(cmd) returns a handler such that naryNoParen(cmd)(prec, args) formats all arguments without outer parentheses. These arguments will be separated by the string cmd.
new: () -> %
new() create a new, empty object. Use setPrologue!, setFormat! and setEpilogue! to set the various components of this object.
nullary: String -> (Integer, List OutputForm) -> List String
nullary(cmd) is a handler to format nullary operators. It simply returns cmd, i.e. cmd must not change it meaning even if some arbitrary string is appended to it. In other words, add a space or a pair of braces after it, if this is necessary.
operatorHandlers: () -> OperatorHandlers (Integer, List OutputForm) -> List String
operatorHandlers() returns an internal data structure that is used for the selection of respective handlers.
operatorWithLimits: (String, Integer) -> (Integer, List OutputForm) -> List String
operatorWithLimits(cmd, p) returns a handler such that operatorWithLimits(cmd, p)(prec, args) formats the arguments without parentheses and interprets the arguments as upper or lower limits/indices of an operator. cmd is assumed to be a TeX operator like $sum$, $prod$, or $int$. Outer parentheses are added if p < prec.
prologue: % -> List String
prologue(t) extracts the prologue section of a TeX form t.
scripts: (String, Integer) -> (Integer, List OutputForm) -> List String
scripts(cmd, p) returns a handler such that scripts(cmd, p)(prec, args) formats the first argument with respect to the precedence p. The other arguments are formatted without parentheses and interpreted as subscript, superscript, presuperscript, and presubscript (in this order). Outer parentheses are added if p < prec.
setEpilogue!: (%, List String) -> List String
setEpilogue!(t, strings) sets the epilogue section of a TeX form t to strings.
setFormat!: (%, List String) -> List String
setFormat!(t, strings) sets the TeX section of a TeX form t to strings.
setPrologue!: (%, List String) -> List String
setPrologue!(t, strings) sets the prologue section of a TeX form t to strings.
theMap: String -> (Integer, List OutputForm) -> List String
theMap(cmd) is a special handler to format a function. The respective function name will be put into the argument of a TeX command given by cmd.
unary: (String, Integer, Integer) -> (Integer, List OutputForm) -> List String
unary(cmd, p, p1) returns a handler such that unary(cmd, p, p1)(prec, args) formats args.1 according to the precedence p1 and puts the result into the argument of the TeX command given by cmd. Outer parentheses are added if p < prec.
unaryNoParen: String -> (Integer, List OutputForm) -> List String
unaryNoParen(cmd) returns a handler such that unaryNoParen(cmd)(prec, args) formats args.1 without outer parentheses and puts the result into the argument of the TeX command given by cmd.

OutputFormatterCategory