### TeX Language Mode

The d T (calc-tex-language) command selects the conventions of "math mode" in the TeX typesetting language, by Donald Knuth. Formulas are entered and displayed in TeX notation, as in \sin\left( a \over b \right)'. Math formulas are usually enclosed by ' signs in TeX; these should be omitted when interfacing with Calc. To Calc, the $' sign has the same meaning it always does in algebraic formulas (a reference to an existing entry on the stack). Complex numbers are displayed as in 3 + 4i'. Fractions and quotients are written using \over; binomial coefficients are written with \choose. Interval forms are written with \ldots, and error forms are written with \pm. Absolute values are written as in |x + 1|', and the floor and ceiling functions are written with \lfloor, \rfloor, etc. The words \left and \right are ignored when reading formulas in TeX mode. Both inf and uinf are written as \infty; when read, \infty always translates to inf. Function calls are written the usual way, with the function name followed by the arguments in parentheses. However, functions for which TeX has special names (like \sin) will use curly braces instead of parentheses for very simple arguments. During input, curly braces and parentheses work equally well for grouping, but when the document is formatted the curly braces will be invisible. Thus the printed result is sin 2x but @c{$\sin(2 + x)\$} sin(2 + x).

Function and variable names not treated specially by TeX are simply written out as-is, which will cause them to come out in italic letters in the printed document. If you invoke d T with a positive numeric prefix argument, names of more than one character will instead be written \hbox{name}'. The \hbox{ }' notation is ignored during reading. If you use a negative prefix argument, such function names are written \name', and function names that begin with \ during reading have the \ removed. (Note that in this mode, long variable names are still written with \hbox. However, you can always make an actual variable name like \bar in any TeX mode.)

During reading, text of the form \matrix{ ... }' is replaced by [ ... ]'. The same also applies to \pmatrix and \bmatrix. The symbol &' is interpreted as a comma, and the symbols \cr' and \\' are interpreted as semicolons. During output, matrices are displayed in \matrix{ a & b \\ c & d}' format; you may need to edit this afterwards to change \matrix to \pmatrix or \\ to \cr.

Accents like \tilde and \bar translate into function calls internally (tilde(x)', bar(x)'). The \underline sequence is treated as an accent. The \vec accent corresponds to the function name Vec, because vec is the name of a built-in Calc function. The following table shows the accents in Calc, TeX, and eqn (described in the next section):

@begingroup @let@calcindexershow=@calcindexernoshow @let@calcindexersh=@calcindexernoshow @endgroup

Calc      TeX           eqn
----      --           ---
acute     \acute
bar       \bar          bar
breve     \breve
check     \check
dot       \dot          dot
dotdot    \ddot         dotdot
grave     \grave
hat       \hat          hat
Prime                   prime
tilde     \tilde        tilde
under     \underline    under
Vec       \vec          vec


The =>' (evaluates-to) operator appears as a \to symbol: {a \to b}'. TeX defines \to as an alias for \rightarrow. However, if the =>' is the top-level expression being formatted, a slightly different notation is used: \evalto a \to b'. The \evalto word is ignored by Calc's input routines, and is undefined in TeX. You will typically want to include one of the following definitions at the top of a TeX file that uses \evalto:

\def\evalto{}
\def\evalto#1\to{}


The first definition formats evaluates-to operators in the usual way. The second causes only the b part to appear in the printed document; the a part and the arrow are hidden. Another definition you may wish to use is \let\to=\Rightarrow' which causes \to to appear more like Calc's =>' symbol. See section The Evaluates-To Operator, for a discussion of evalto.

The complete set of TeX control sequences that are ignored during reading is:

\hbox  \mbox  \text  \left  \right
\displaystyle  \textstyle  \dsize  \tsize
\scriptstyle  \scriptscriptstyle  \ssize  \ssize
\rm  \bf  \it  \sl  \roman  \bold  \italic  \slanted
\cal  \mit  \Cal  \Bbb  \frak  \goth
\evalto


Note that, because these symbols are ignored, reading a TeX formula into Calc and writing it back out may lose spacing and font information.

Also, the "discretionary multiplication sign" \*' is read the same as *'.

Here are some examples of how various Calc formulas are formatted in TeX:

sin(a^2 / b_i)
\sin\left( {a^2 \over b_i} \right)


[(3, 4), 3:4, 3 +/- 4, [3 .. inf)]
[3 + 4i, {3 \over 4}, 3 \pm 4, [3 \ldots \infty)]


[abs(a), abs(a / b), floor(a), ceil(a / b)]
[|a|, \left| a \over b \right|,
\lfloor a \rfloor, \left\lceil a \over b \right\rceil]


[sin(a), sin(2 a), sin(2 + a), sin(a / b)]
[\sin{a}, \sin{2 a}, \sin(2 + a),
\sin\left( {a \over b} \right)]


First with plain d T, then with C-u d T, then finally with C-u - d T (using the example definition \def\foo#1{\tilde F(#1)}':


[f(a), foo(bar), sin(pi)]
[f(a), foo(bar), \sin{\pi}]
[f(a), \hbox{foo}(\hbox{bar}), \sin{\pi}]
[f(a), \foo{\hbox{bar}}, \sin{\pi}]


First with \def\evalto{}', then with \def\evalto#1\to{}':


2 + 3 => 5
\evalto 2 + 3 \to 5


First with standard \to, then with \let\to\Rightarrow':


[2 + 3 => 5, a / 2 => (b + c) / 2]
[{2 + 3 \to 5}, {{a \over 2} \to {b + c \over 2}}]


Matrices normally, then changing \matrix to \pmatrix:


[ [ a / b, 0 ], [ 0, 2^(x + 1) ] ]
\matrix{ {a \over b} & 0 \\ 0 & 2^{(x + 1)} }
\pmatrix{ {a \over b} & 0 \\ 0 & 2^{(x + 1)} }