1
2High quality typesetting of mathematical formulas is a quite tedious
3task.  One of the most sophisticated typesetting programs for
4mathematical text \TeX{} \cite{Knuth:84}, together with its widely used
5macro package \LaTeX{} \cite{Lamport:86}, has a strange syntax of
6mathematical formulas, especially of the complicated type.  This is the
7main reason which lead us to designing the formula interface between the
8computer algebra system \REDUCE{} and the document preparation system
9\LaTeX{}.  The other reason is that all available syntaxes of the
10\REDUCE{} formula output are line oriented and thus not suitable for
11typesetting in mathematical text.  The idea of interfacing a computer
12algebra system to a typesetting program has already been used, eg.  in
13\cite{Fateman:87} presenting the \TeX{} output of the MACSYMA computer
14algebra system.
15
16The formula interface presented here adds to \REDUCE{} the new syntax of
17formula output, namely \LaTeX{} syntax, and can also be named \REDUCE{} -
18\LaTeX{} translator.  Text generated by \REDUCE{} in this syntax can be
19directly used in \LaTeX{} source documents.  Various mathematical
20constructions are supported by the interface including subscripts,
21superscripts, font changing, Greek letters, divide-bars, integral and
22sum signs, derivatives etc.
23
24The interface can be used in two ways:
25\begin{itemize}
26\item for typesetting of results of \REDUCE{} algebraic calculations.
27\item for typesetting of users formulas.
28\end{itemize}
29
30The latter can even be used by users unfamiliar with the \REDUCE{}
31system, because the \REDUCE{} input syntax of formulas is almost the
32same as the syntax of the majority of programming languages.  We aimed
33at speeding up the process of formula typesetting, because we are
34convinced, that the writing of correct complicated formulas in the
35\REDUCE{} syntax is a much more simpler task than writing them in the
36\LaTeX{} syntax full of keywords and special characters \verb+ \, {, ^+
37etc.  It is clear, that not every formula produced by the interface is
38typeset in the best format from an aesthetic point of view.  When a user
39is not satisfied with the result, he can add some \LaTeX{} commands to the
40\REDUCE{} output - \LaTeX{} input.
41
42The interface is connected to \REDUCE{} by three new switches and
43several statements.  To activate the \LaTeX{} output mode the switch {\tt
44latex} must be set {\tt on}.  this switch, similar to the switch {\tt
45fort} producing FORTRAN output, being {\tt on} causes all outputs to be
46written in the \LaTeX{} syntax of formulas.  The switch {\tt VERBATIM} is
47used for input printing control.  If it is {\tt on} input to \REDUCE{} system
48is typeset in \LaTeX{} verbatim environment after the line containing
49the string {\tt REDUCE Input:}.
50
51The switch {\tt lasimp} controls the algebraic evaluation of input
52formulas.  If it is {\tt on} every formula is evaluated, simplified and
53written in the form given by ordinary \REDUCE{} statements and switches
54such as {\tt factor}, {\tt order}, {\tt rat} etc.  In the case when the
55{\tt lasimp} switch is {\tt off} evaluation, simplification or
56reordering of formulas is not performed and \REDUCE{} acts only as a
57formula parser and the form of the formula output is exactly the same as
58that of the input, the only difference remains in the syntax.  The mode
59{\tt off lasimp} is designed especially for typesetting of formulas for
60which the user needs preservation of their structure.  This switch has
61no meaning if the switch {\tt Latex} is {\tt off} and thus is working
62only for \LaTeX{} output.
63
64For every  identifier  used  in  the  typeset  \REDUCE{}  formula
65the following properties can be defined by the statement {\tt defid}:
66\begin{itemize}
67\item its printing symbol (Greek letters can be used).
68\item the font in which the symbol will be typeset.
69\item accent which will be typeset above the symbol.
70\end{itemize}
71
72Symbols with indexes are treated in \REDUCE{} as operators.  Each index
73corresponds to an argument of the operator.  The meaning of operator
74arguments (where one wants to typeset them) is declared by the statement
75{\tt defindex}.  This statement causes the arguments to be typeset as
76subscripts or superscripts (on left or right-hand side of the operator)
77or as arguments of the operator.
78
79The statement {\tt mathstyle} defines the style of formula typesetting.
80The variable {\tt laline!*} defines the length of output lines.
81
82The fractions with horizontal divide bars are typeset by using the
83new \REDUCE{} infix operator \verb+//+.  This operator is not
84algebraically simplified.  During typesetting of powers the checking on
85the form of the power base and exponent is performed to determine the
86form of the typeset expression (eg.  sqrt symbol, using parentheses).
87
88Some special forms can be typeset by using \REDUCE{} prefix operators.
89These are as follows:
90\begin{itemize}
91\item {\tt int} - integral of an expression.
92\item {\tt dint} - definite integral of an expression.
93\item {\tt df} - derivative of an expression.
94\item {\tt pdf} - partial derivative of an expression.
95\item {\tt sum} - sum of expressions.
96\item {\tt product} - product of expressions.
97\item {\tt sqrt} - square root of expression.
98\end{itemize}
99There are still some problems unsolved in the present version of the
100interface as follows:
101\begin{itemize}
102\item breaking the formulas which do not fit on one line.
103\item automatic decision where to use divide bars in fractions.
104\item distinction of two- or more-character identifiers from the product
105  of one-character symbols.
106\item typesetting of matrices.
107\end{itemize}
108
109
110
111\centerline{\bf Remark}
112
113After finishing presented interface, we have found another work
114\cite{Antweiler:89}, which solves the same problem. The RLFI package has
115been described in \cite{Drska:90} too.
116
117
118
119
120\subsection{APPENDIX: Summary and syntax}
121
122{\bf Warning}
123
124The RLFI package can be used only on systems supporting lower case
125letters with {\tt off raise} statement. The package distinquishes the
126upper and lower case letters, so be carefull in typing them.
127In \REDUCE 3.6 the \REDUCE commands have to be typed in lower-case
128while the switch {\tt latex} is {\tt on}, in previous versions
129the commands had to be typed in upper-case.
130
131{\bf Switches}
132
133\begin{description}
134\item[{\tt latex}]
135- If {\tt on} output is in \LaTeX{} format. It turns {\tt off} the {\tt
136raise} switch if it is set {\tt on} and {\tt on} the {\tt raise} switch
137if it is set {\tt off}. By default is {\tt off}.
138\item[{\tt lasimp}]
139- If {\tt on} formulas are evaluated (simplified), \REDUCE{} works
140as usually. If {\tt off} no evaluation is performed and the structure
141of formulas is preserved. By default is {\tt on}.
142\item[{\tt verbatim}]
143- If {\tt on} the \REDUCE{} input, while {\tt latex} switch being {\tt
144on}, is printed in \LaTeX{} verbatim environment. The acutal \REDUCE{}
145input is printed after the line containing the string {\tt "REDUCE
146Input:"}.  It turns {\tt on} resp. {\tt off} the {\tt echo} switch when
147turned {\tt on} resp. {\tt off}. by default is {\tt off}.
148\end{description}
149
150{\bf Operators}
151
152\begin{description}
153\item[infix] - \verb+//+
154\item[prefix] - {\tt int,dint,df,pdf,sum,product,sqrt} and all \REDUCE{}
155prefix operators defined in the \REDUCE{} kernel and the SOLVE module.
156\end{description}
157
158\begin{verbatim}
159   <alg. expression> // <alg. expression>
160   int(<function>,<variable>)
161   dint(<from>,<to>,<function>,<variable>)
162   df(<function>,<variables>)
163   <variables> ::= <o-variable>|<o-variable>,<variables>
164   <o-variable> ::= <variable>|<variable>,<order>
165   <variable> ::= <kernel>
166   <order> ::= <integer>
167   <function> ::= <alg. expression>
168   <from> ::= <alg. expression>
169   <to> ::= <alg. expression>
170   pdf(<function>,<variables>)
171   sum(<from>,<to>,<function>)
172   product(<from>,<to>,<function>)
173   sqrt(<alg. expression>)
174\end{verbatim}
175
176{\tt <alg. expression>} is any algebraic expression. Where appropriate,
177it can include also relational operators (e.g. argument {\tt <from>} of
178{\tt sum} or {\tt product} operators is usually equation). {\tt
179<kernel>} is identifier or prefix operator with arguments as described
180in \cite{Hearn:91}. Interface supports typesetting lists of algebraic
181expressions.
182
183
184{\bf Statements}
185
186\begin{verbatim}
187   mathstyle <m-style>;
188   <m-style> ::= math | displaymath | equation
189   defid <identifier>,<d-equations>;
190   <d-equations> ::= <d-equation> | <d-equation>,<d-equations>
191   <d-equation> ::= <d-print symbol> | <d-font>|<d-accent>
192   <d-print symbol> ::= name = <print symbol>
193   <d-font> ::= font = <font>
194   <d-accent> ::= accent = <accent>
195   <print symbol> ::= <character> | <special symbol>
196   <special symbol> ::= alpha|beta|gamma|delta|epsilon|
197      varepsilon|zeta|eta|theta|vartheta|iota|kappa|lambda|
198      mu|nu|xi|pi|varpi|rho|varrho|sigma|varsigma|tau|
199      upsilon|phi|varphi|chi|psi|omega|Gamma|Delta|Theta|
200      Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega|infty|hbar
201   <font> ::= bold|roman
202   <accent> ::=hat|check|breve|acute|grave|tilde|bar|vec|
203      dot|ddot
204\end{verbatim}
205
206For special symbols and accents see \cite{Lamport:86}, p. 43, 45, 51.
207
208\begin{verbatim}
209   defindex <d-operators>;
210   <d-operators> ::= <d-operator> | <d-operator>,<d-operators>
211   <d-operator> ::= <prefix operator>(<descriptions>)
212   <prefix operator> ::= <identifier>
213   <descriptions> ::= <description> | <description>,
214      <descriptions>
215   <description> ::= arg | up | down | leftup | leftdown
216\end{verbatim}
217
218The meaning of the statements is briefly described in the preceding
219text.
220