File r38/doc/manual2/tri.tex artifact 2fdf8887a9 part of check-in 255e9d69e6


\chapter{TRI: TeX REDUCE interface}
\label{TRI}
\typeout{{TRI: TeX REDUCE interface}}

{\footnotesize
\begin{center}
Werner Antweiler, Andreas Strotmann and Volker Winkelmann \\
University of Cologne Computer Center,
Abt. Anwendungssoftware, Robert-Koch-Stra\ss{e} 10 \\
5000 K"oln 41, Germany \\[0.05in]
e--mail: antweil@epas.utoronto.ca strotmann@rrz.uni-koeln.de winkelmann@rrz.uni-koeln.de
\end{center}
}
\ttindex{TRI}

The \REDUCE-\TeX-Interface incorporates three
levels of \TeX\ output: without line breaking, with line breaking,
and with line breaking plus indentation.

During loading the package some default initialisations are performed.
The default page width is set to 15 centimetres, the tolerance for
page breaking is set to 20 by default.  Moreover, TRI is enabled 
to translate Greek names, {\em e.g.\ }TAU or PSI, into equivalent \TeX\
symbols, {\em e.g.\ } $\tau$ or $\psi$, respectively.  Letters are
printed lowercase as defined through assertion of the set
LOWERCASE.

\section{Switches for TRI}

The three TRI modes can be selected by switches, which can be used
alternatively and incrementally.  Switching {\tt TEX}\ttindex{TEX} on
gives standard \TeX-output; switching {\tt TEXBREAK}\ttindex{TEXBREAK}
gives broken \TeX-output, and {\tt TEXINDENT}\ttindex{TEXINDENT} to
give broken  \TeX-output plus indentation.  Thus the three levels of
TRI are enabled or disabled according to: 
\begin{verbatim}
    On TeX;          % switch TeX is on
    On TeXBreak;     % switches TeX and TeXBreak are on
    On TeXIndent;    % switches TeX, TeXBreak and TeXIndent are on
    Off TeXIndent;   % switch TeXIndent is off
    Off TeXBreak;    % switches TeXBreak and TeXIndent are off
    Off TeX;         % all three switches are off
\end{verbatim}

How TRI breaks multiple lines of \TeX-code may be controlled by
setting  values for page width and tolerance\ttindex{TeXsetbreak}
\begin{verbatim}
    TeXsetbreak(page_width, tolerance);
\end{verbatim}

Page width is measured in millimetres, and tolerance is a positive
integer in the closed interval $[0\ldots10000]$.\index{TRI ! page-width}
The higher the tolerance, the more breakpoints become feasible.
A tolerance of 0 means that actually no breakpoint will be considered
feasible, while a value of 10000 allows any breakpoint to be
considered feasible.\index{TRI ! tolerance}
For line-breaking without indentation, suitable values for the
tolerance lie between 10 and 100.  As a rule of thumb, use
higher values the deeper the term is nested.  If using indentation,
use much higher tolerance values; reasonable values for
tolerance here lie between 700 and 1500.


\subsection{Adding Translations}

Sometimes it is desirable to add special REDUCE-symbol-to-\TeX-item
translations.  For such a task TRI provides a function
{\tt TeXlet} which binds any REDUCE-symbol to one of the predefined
\TeX-items.  A call to this function has the following syntax:
\ttindex{TeXlet}

{\tt TeXlet}({\em REDUCE-symbol}, {\em \TeX-item});

For example
\begin{verbatim}
    TeXlet('velocity,'!v);
    TeXlet('gamma,\verb|'!\!G!a!m!m!a! |);
    TeXlet('acceleration,\verb|'!\!v!a!r!t!h!e!t!a! |);
\end{verbatim}

Besides this method of single assertions one can assert
one of (currently) two standard sets providing substitutions
for lowercase and Greek letters.  These sets are loaded by default.
These sets can be switched on or off using the functions

\noindent{\tt TeXassertset} {\em setname};\\
\noindent{\tt TeXretractset} {\em setname};

where the setnames currently defined are {\tt 'GREEK} and {\tt 'LOWERCASE}.

There are facilities for creating other sets of substitutions, using
the function {\tt TeXitem}\ttindex{TeXitem}.

\section{Examples of Use}

Some representative examples demonstrate the capabilities of TRI.

\begin{verbatim}
load_package tri;
    % TeX-REDUCE-Interface 0.50
    % set greek asserted
    % set lowercase asserted
    % \tolerance 10
    % \hsize=150mm

TeXsetbreak(150,250);
    % \tolerance 250
    % \hsize=150mm

on TeXindent;

(x+y)^16/(v-w)^16;
    $$\displaylines{\qdd
    \(x^{16}
      +16\cdot x^{15}\cdot y
      +120\cdot x^{14}\cdot y^{2}
      +560\cdot x^{13}\cdot y^{3}
      +1820\cdot x^{12}\cdot y^{4}
      +4368\cdot x^{11}\cdot y^{5}\nl
      \off{327680}
      +8008\cdot x^{10}\cdot y^{6}
      +11440\cdot x^{9}\cdot y^{7}
      +12870\cdot x^{8}\cdot y^{8}
      +11440\cdot x^{7}\cdot y^{9}
      +8008\cdot x^{6}\cdot y^{10}\nl
      \off{327680}
      +4368\cdot x^{5}\cdot y^{11}
      +1820\cdot x^{4}\cdot y^{12}
      +560\cdot x^{3}\cdot y^{13}
      +120\cdot x^{2}\cdot y^{14}
      +16\cdot x\cdot y^{15}
      +y^{16}
    \)
    /\nl
    \(v^{16}
      -16\cdot v^{15}\cdot w
      +120\cdot v^{14}\cdot w^{2}
      -560\cdot v^{13}\cdot w^{3}
      +1820\cdot v^{12}\cdot w^{4}
      -4368\cdot v^{11}\cdot w^{5}\nl
      \off{327680}
      +8008\cdot v^{10}\cdot w^{6}
      -11440\cdot v^{9}\cdot w^{7}
      +12870\cdot v^{8}\cdot w^{8}
      -11440\cdot v^{7}\cdot w^{9}
      +8008\cdot v^{6}\cdot w^{10}
      -4368\cdot v^{5}\cdot w^{11}\nl
      \off{327680}
      +1820\cdot v^{4}\cdot w^{12}
      -560\cdot v^{3}\cdot w^{13}
      +120\cdot v^{2}\cdot w^{14}
      -16\cdot v\cdot w^{15}
      +w^{16}
    \)
    \Nl}$$
\end{verbatim}

A simple example using matrices:
\begin{verbatim}
load_package ri;
    % TeX-REDUCE-Interface 0.50
    % set greek asserted
    % set lowercase asserted
    % \tolerance 10
    % \hsize=150mm

on Tex;

mat((1,a-b,1/(c-d)),(a^2-b^2,1,sqrt(c)),((a+b)/(c-d),sqrt(d),1));
    $$
    \pmatrix{1&a
             -b&
             \frac{1}{
                   c
                   -d}\cr
             a^{2}
             -b^{2}&1&
             \sqrt{c}\cr
             \frac{a
                   +b}{
                   c
                   -d}&
             \sqrt{d}&1\cr
             }
    $$
\end{verbatim}

Note that the resulting output uses a number of \TeX\ macros which are
defined in the file {\tt tridefs.tex} which is distributed with the
example file.



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