tri.tex 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. \chapter{TRI: TeX REDUCE interface}
  2. \label{TRI}
  3. \typeout{{TRI: TeX REDUCE interface}}
  4. {\footnotesize
  5. \begin{center}
  6. Werner Antweiler, Andreas Strotmann and Volker Winkelmann \\
  7. University of Cologne Computer Center,
  8. Abt. Anwendungssoftware, Robert-Koch-Stra\ss{e} 10 \\
  9. 5000 K"oln 41, Germany \\[0.05in]
  10. e--mail: antweil@epas.utoronto.ca strotmann@rrz.uni-koeln.de winkelmann@rrz.uni-koeln.de
  11. \end{center}
  12. }
  13. \ttindex{TRI}
  14. The \REDUCE-\TeX-Interface incorporates three
  15. levels of \TeX\ output: without line breaking, with line breaking,
  16. and with line breaking plus indentation.
  17. During loading the package some default initialisations are performed.
  18. The default page width is set to 15 centimetres, the tolerance for
  19. page breaking is set to 20 by default. Moreover, TRI is enabled
  20. to translate Greek names, {\em e.g.\ }TAU or PSI, into equivalent \TeX\
  21. symbols, {\em e.g.\ } $\tau$ or $\psi$, respectively. Letters are
  22. printed lowercase as defined through assertion of the set
  23. LOWERCASE.
  24. \section{Switches for TRI}
  25. The three TRI modes can be selected by switches, which can be used
  26. alternatively and incrementally. Switching {\tt TEX}\ttindex{TEX} on
  27. gives standard \TeX-output; switching {\tt TEXBREAK}\ttindex{TEXBREAK}
  28. gives broken \TeX-output, and {\tt TEXINDENT}\ttindex{TEXINDENT} to
  29. give broken \TeX-output plus indentation. Thus the three levels of
  30. TRI are enabled or disabled according to:
  31. \begin{verbatim}
  32. On TeX; % switch TeX is on
  33. On TeXBreak; % switches TeX and TeXBreak are on
  34. On TeXIndent; % switches TeX, TeXBreak and TeXIndent are on
  35. Off TeXIndent; % switch TeXIndent is off
  36. Off TeXBreak; % switches TeXBreak and TeXIndent are off
  37. Off TeX; % all three switches are off
  38. \end{verbatim}
  39. How TRI breaks multiple lines of \TeX-code may be controlled by
  40. setting values for page width and tolerance\ttindex{TeXsetbreak}
  41. \begin{verbatim}
  42. TeXsetbreak(page_width, tolerance);
  43. \end{verbatim}
  44. Page width is measured in millimetres, and tolerance is a positive
  45. integer in the closed interval $[0\ldots10000]$.\index{TRI ! page-width}
  46. The higher the tolerance, the more breakpoints become feasible.
  47. A tolerance of 0 means that actually no breakpoint will be considered
  48. feasible, while a value of 10000 allows any breakpoint to be
  49. considered feasible.\index{TRI ! tolerance}
  50. For line-breaking without indentation, suitable values for the
  51. tolerance lie between 10 and 100. As a rule of thumb, use
  52. higher values the deeper the term is nested. If using indentation,
  53. use much higher tolerance values; reasonable values for
  54. tolerance here lie between 700 and 1500.
  55. \subsection{Adding Translations}
  56. Sometimes it is desirable to add special REDUCE-symbol-to-\TeX-item
  57. translations. For such a task TRI provides a function
  58. {\tt TeXlet} which binds any REDUCE-symbol to one of the predefined
  59. \TeX-items. A call to this function has the following syntax:
  60. \ttindex{TeXlet}
  61. {\tt TeXlet}({\em REDUCE-symbol}, {\em \TeX-item});
  62. For example
  63. \begin{verbatim}
  64. TeXlet('velocity,'!v);
  65. TeXlet('gamma,\verb|'!\!G!a!m!m!a! |);
  66. TeXlet('acceleration,\verb|'!\!v!a!r!t!h!e!t!a! |);
  67. \end{verbatim}
  68. Besides this method of single assertions one can assert
  69. one of (currently) two standard sets providing substitutions
  70. for lowercase and Greek letters. These sets are loaded by default.
  71. These sets can be switched on or off using the functions
  72. \noindent{\tt TeXassertset} {\em setname};\\
  73. \noindent{\tt TeXretractset} {\em setname};
  74. where the setnames currently defined are {\tt 'GREEK} and {\tt 'LOWERCASE}.
  75. There are facilities for creating other sets of substitutions, using
  76. the function {\tt TeXitem}\ttindex{TeXitem}.
  77. \section{Examples of Use}
  78. Some representative examples demonstrate the capabilities of TRI.
  79. \begin{verbatim}
  80. load_package tri;
  81. % TeX-REDUCE-Interface 0.50
  82. % set greek asserted
  83. % set lowercase asserted
  84. % \tolerance 10
  85. % \hsize=150mm
  86. TeXsetbreak(150,250);
  87. % \tolerance 250
  88. % \hsize=150mm
  89. on TeXindent;
  90. (x+y)^16/(v-w)^16;
  91. $$\displaylines{\qdd
  92. \(x^{16}
  93. +16\cdot x^{15}\cdot y
  94. +120\cdot x^{14}\cdot y^{2}
  95. +560\cdot x^{13}\cdot y^{3}
  96. +1820\cdot x^{12}\cdot y^{4}
  97. +4368\cdot x^{11}\cdot y^{5}\nl
  98. \off{327680}
  99. +8008\cdot x^{10}\cdot y^{6}
  100. +11440\cdot x^{9}\cdot y^{7}
  101. +12870\cdot x^{8}\cdot y^{8}
  102. +11440\cdot x^{7}\cdot y^{9}
  103. +8008\cdot x^{6}\cdot y^{10}\nl
  104. \off{327680}
  105. +4368\cdot x^{5}\cdot y^{11}
  106. +1820\cdot x^{4}\cdot y^{12}
  107. +560\cdot x^{3}\cdot y^{13}
  108. +120\cdot x^{2}\cdot y^{14}
  109. +16\cdot x\cdot y^{15}
  110. +y^{16}
  111. \)
  112. /\nl
  113. \(v^{16}
  114. -16\cdot v^{15}\cdot w
  115. +120\cdot v^{14}\cdot w^{2}
  116. -560\cdot v^{13}\cdot w^{3}
  117. +1820\cdot v^{12}\cdot w^{4}
  118. -4368\cdot v^{11}\cdot w^{5}\nl
  119. \off{327680}
  120. +8008\cdot v^{10}\cdot w^{6}
  121. -11440\cdot v^{9}\cdot w^{7}
  122. +12870\cdot v^{8}\cdot w^{8}
  123. -11440\cdot v^{7}\cdot w^{9}
  124. +8008\cdot v^{6}\cdot w^{10}
  125. -4368\cdot v^{5}\cdot w^{11}\nl
  126. \off{327680}
  127. +1820\cdot v^{4}\cdot w^{12}
  128. -560\cdot v^{3}\cdot w^{13}
  129. +120\cdot v^{2}\cdot w^{14}
  130. -16\cdot v\cdot w^{15}
  131. +w^{16}
  132. \)
  133. \Nl}$$
  134. \end{verbatim}
  135. A simple example using matrices:
  136. \begin{verbatim}
  137. load_package ri;
  138. % TeX-REDUCE-Interface 0.50
  139. % set greek asserted
  140. % set lowercase asserted
  141. % \tolerance 10
  142. % \hsize=150mm
  143. on Tex;
  144. mat((1,a-b,1/(c-d)),(a^2-b^2,1,sqrt(c)),((a+b)/(c-d),sqrt(d),1));
  145. $$
  146. \pmatrix{1&a
  147. -b&
  148. \frac{1}{
  149. c
  150. -d}\cr
  151. a^{2}
  152. -b^{2}&1&
  153. \sqrt{c}\cr
  154. \frac{a
  155. +b}{
  156. c
  157. -d}&
  158. \sqrt{d}&1\cr
  159. }
  160. $$
  161. \end{verbatim}
  162. Note that the resulting output uses a number of \TeX\ macros which are
  163. defined in the file {\tt tridefs.tex} which is distributed with the
  164. example file.