File r34.1/lib/rlfi.doc artifact 84a1697e9c part of check-in d9e362f11e


1


                 REDUCE LATEX Formula Interface
                           ( RLFI )

                        Ver. 1.1  05/91


                  Richard Liska, Ladislav Drska

                   Computational Physics Group
        Faculty of Nuclear Sciences and Physical Engineering
               Czech Technical University in Prague
           Brehova 7, 115 19 Prague 1, Czechoslovakia
                  E-mail: tjerl@cspuni12.bitnet



High  quality  typesetting of mathematical formulas is a quite tedious
task.   One  of  the  most  sophisticated  typesetting  programs   for
mathematical text TEX [1], together with its widely used macro package
LATEX [2], has a strange syntax of mathematical  formulas,  especially
of  the  complicated  type.   This is the main reason which lead us to
designing the formula interface between the  computer  algebra  system
REDUCE  [3]  and  the  document  preparation  system LATEX.  The other
reason is that all available syntaxes of the REDUCE formula output are
line  oriented  and  thus not suitable for typesetting in mathematical
text.  The  idea  of  interfacing  a  computer  algebra  system  to  a
typesetting  program has already been used, eg.  in [4] presenting the
TeX output of the MACSYMA computer algebra system.

The formula interface presented here adds to REDUCE the new syntax  of
formula  output,  namely  LATEX syntax, and can also be named REDUCE -
LATEX translator.  Text generated by REDUCE  in  this  syntax  can  be
directly   used  in  LATEX  source  documents.   Various  mathematical
constructions are supported by  the  interface  including  subscripts,
superscripts,  font changing, Greek letters, divide-bars, integral and
sum signs, derivatives etc.

The interface can be used in two ways:

- for typesetting of results of REDUCE algebraic calculations.
- for typesetting of users formulas.

The latter can even be  used  by  users  unfamiliar  with  the  REDUCE
system, because the REDUCE input syntax of formulas is almost the same
as the syntax of the majority of programming languages.  We  aimed  at
speeding  up  the  process  of  formula  typesetting,  because  we are
convinced, that the writing of correct  complicated  formulas  in  the
REDUCE  syntax  is  a  much more simpler task than writing them in the
LATEX syntax full of keywords and special characters \, {, ^ etc.   It
is  clear,  that  not  every  formula  produced  by  the  interface is
typeset  in  the  best format from an aesthetic point of view.  When a
user  is not satisfied with the result, he can add some LATEX commands
to the REDUCE output - LATEX input.

The interface is connected to REDUCE by three new switches and several
statements.   To  activate the LATEX output mode the switch LATEX must
be set ON.  This switch, similar to the switch FORT producing  FORTRAN
1output,  being ON causes all outputs to be written in the LATEX syntax
of formulas.  The switch VERBATIM is used for input printing  control.
If  it  is  ON input to REDUCE system is  typesetted in LATEX verbatim
environment.

The switch LASIMP controls the algebraic evaluation of input formulas.
If  it is ON every formula is evaluated, simplified and written in the
form given by ordinary REDUCE statements and switches such as  FACTOR,
ORDER, RAT etc.  In the case when the LASIMP switch is OFF evaluation,
simplification or reordering of formulas is not performed  and  REDUCE
acts  only  as  a formula parser and the form of the formula output is
exactly the same as that of the input, the only difference remains  in
the   syntax.    The  mode  OFF  LASIMP  is  designed  especially  for
typesetting of formulas for which the user needs preservation of their
structure.   This switch has no meaning if the switch LATEX is OFF and
thus is working only for LATEX output.

For every  identifier  used  in  the  typesetted  REDUCE  formula  the
following properties can be defined by the statement DEFID:

- its printing symbol (Greek letters can be used).
- the font in which the symbol will be typesetted.
- accent which will be typesetted above the symbol.

Symbols  with  indexes are treated in REDUCE as operators.  Each index
corresponds to an argument of the operator.  The meaning  of  operator
arguments  (where  one  wants  to  typeset  them)  is  declared by the
statement  DEFINDEX.   This  statement  causes  the  arguments  to  be
typesetted  as  subscripts or superscripts (on left or right-hand side
of the operator) or as arguments of the operator.

Statement  mathstyle  defines  the  style  of   formula   typesetting.
Variable LALINE!* defines the length of output lines.

The  fractions with horizontal divide bars are typesetted by using the
new REDUCE infix operator  \.   This  operator  is  not  algebraically
simplified.   During typesetting of powers the checking on the form of
the power base and exponent is performed to determine the form of  the
typesetted expression (eg.  sqrt symbol, using parentheses).

Some  special  forms  can be typeset by using REDUCE prefix operators.
These are as follows:

- INT - integral of an expression.
- DINT - definite integral of an expression.
- DF - derivative of an expression.
- PDF - partial derivative of an expression.
- SUM - sum of expressions.
- PRODUCT - product of expressions.
- SQRT - square root of expression.

There are still some problems unsolved in the present version  of  the
interface as follows:

- breaking the formulas which do not fit on one line.
- automatic decision where to use divide bars in fractions.
- distinction of two- or more-character identifiers from the product of
  one-character symbols.
- typesetting of matrices.

                     Description of files

RLFI.RED - REDUCE source file for this interface, file RLFI in the
           test file RLFI.TST
RLFI.DOC - this document
RLFI.TST - test file for this interface
RLFI.LOG - LATEX output of the test session, file TEX in the test
           file RLFI.TST, can be directly used as LATEX input file.


                            Remark

After  finishing  presented interface, we have found another work [5],
which solves the same problem. The RLFI package has been described in
[6] too.



                           References

[1] D.E. Knuth, The TeX book (Addison-Wesley, Reading, 1984).
[2] L. Lamport, LATEX A Document Preparation System (Addison-Wesley,
            Reading 1986).
[3] A.C. Hearn, REDUCE User's Manual, Ver  3.4 (The RAND Corporation,
            Santa Monica 1991).
[4] J.R. Fateman,  ACM SIGSAM Bulletin 21 (1987) 4.
[5] W. Antweiler, A. Strotmann and V. Winkelmann, ACM SIGSAM Bulletin
            23 (1989) 26.
[6] L. Drska, R. Liska,  M. Sinor, Two practical packages for
            computational physics - GCPM, RLFI, Comp. Phys. Comm., 61,
            (1990), 225 - 230.



                  APPENDIX: Summary and syntax


     Warning

The RLFI package can be used only on systems supporting lower case
letters with OFF RAISE statement. The package distinquishes the
upper and lower case letters, so be carefull in typing them.

     Switches

LATEX - If ON output is in LATEX format. It turns OFF the RAISE
        switch if it is set ON and ON the RAISE switch if set OFF.
        It turns OFF resp. ON the RAISE switch when turned ON resp.
        OFF. By default is OFF.
LASIMP - If ON formulas are evaluated (simplified), REDUCE works
        as usually. If OFF no evaluation is performed and the structure
        of formulas is preserved. By default is ON.
VERBATIM - If ON REDUCE input, while LATEX switch being ON, is
        printed in LATEX verbatim environment. It turns ON resp. OFF the
        ECHO switch when turned ON resp. OFF. By default is ON.


     Operators

infix - \
1prefix - INT,DINT,DF,PDF,SUM,PRODUCT,SQRT

<alg. expression> \ <alg. expression>
INT(<function>,<variable>)
DINT(<from>,<to>,<function>,<variable>)
DF(<function>,<variables>)
<variables> ::= <o-variable>|<o-variable>,<variables>
<o-variable> ::= <variable>|<variable>,<order>
<variable> ::= <kernel>
<order> ::= <integer>
<function> ::= <alg. expression>
<from> ::= <alg. expression>
<to> ::= <alg. expression>
PDF(<function>,<variables>)
SUM(<from>,<to>,<function>)
PRODUCT(<from>,<to>,<function>)
SQRT(<alg. expression>)

<alg. expression> is any algebraic expression. Where appropriate, it
can include also relational operators (e.g. argument <from> of SUM or
PRODUCT operators is usually equation). <kernel> is identifier or
prefix operator with arguments as described in [3].


     Statements

MATHSTYLE <m-style>;
<m-style> ::= math | displaymath | equation
DEFID <identifier>,<d-equations>;
<d-equations> ::= <d-equation> | <d-equation>,<d-equations>
<d-equation> ::= <d-print symbol> | <d-font>|<d-accent>
<d-print symbol> ::= NAME = <print symbol>
<d-font> ::= FONT = <font>
<d-accent> ::= ACCENT = <accent>
<print symbol> ::= <character> | <special symbol>
<special symbol> ::= alpha|beta|gamma|delta|epsilon|varepsilon|zeta|
       eta|theta|vartheta|iota|kappa|lambda|mu|nu|xi|pi|varpi|rho|
       varrho|sigma|varsigma|tau|upsilon|phi|varphi|chi|psi|omega|
       Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega|
       infty|hbar           (see [2] p.43,45)
<font> ::= bold|roman
<accent> ::=hat|check|breve|acute|grave|tilde|bar|vec|dot|ddot
                            (see [2] p.51)
DEFINDEX <d-operators>;
<d-operators> ::= <d-operator> | <d-operator>,<d-operators>
<d-operator> ::= <prefix operator>(<descriptions>)
<prefix operator> ::= <identifier>
<descriptions> ::= <description> | <description>,<descriptions>
<description> ::= ARG | UP | DOWN | LEFTUP | LEFTDOWN

The meaning of the statements is briefly described in the preceding text.


REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]