www.delorie.com/gnu/docs/calc/calc_177.html   search  
 
Buy the book!


GNU Emacs Calc 2.02 Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.8.3 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 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):

 
Calc      TeX           eqn
----      ---           ---
acute     \acute
bar       \bar          bar
breve     \breve        
check     \check
dot       \dot          dot
dotdot    \ddot         dotdot
dyad                    dyad
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 13.5 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
\,  \>  \:  \;  \!  \quad  \qquad  \hfil  \hfill
\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 `*'.

The TeX version of this manual includes some printed examples at the end of this section.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003