A Latex Document Style Option for Typesetting
Total Page:16
File Type:pdf, Size:1020Kb
TUGboat, Volume 11 (1990), No. 4 many text-processing and desktop-publishing sys- APL code tems still lack APL support, it remains difficult to I achieve high printing quality in publications com- posed of text and APL code. Several extensions APL Front end to existing text processors have been implemented r-l (cf. [Hohti, Kanerva 881). However, most of them support either only the symbols of one APL dialect or only one machine or operating system platform. [Hohti, Kanerva 881 already demonstrated the use- fulness of w for APL typesetting. The authors produced a METAFONT description for APL prim- DVI code itive symbols and a set of TJ$ macros to support Digital's APL interpreter for the VAX-11 series. Figure 1: Modulesqros of the Publishing System In this paper we present our solution to the problem: An APL publishing system consisting of an APL front end and a Urn document style op- matting layer is the printing of single APL symbols. tion. The APL front end automatically converts The APL front end maps each symbol into a T)$ APL material into IPWcode which you can \input macro name and produces files to be \input into into any standard I4w document. The I4w doc- IPwdocuments. The UTJ$ style option apl.sty ument style option apl . sty provides macros defin- contains one macro definition for each APL charac- ing all APL characters as combinations of standard ter. IPwsymbols, thus relieving us from the burden APL code is more than just a stream of APL of designing new fonts and the user from the task symbols. The high level formatting layer knows of incorporating them into the IPwsystem. As about functions, operators, arrays, and expressions. additional benefit, size and type style of the APL Our APL front end provides special functions for symbols can be changed by the familiar IPwcom- typesetting these objects. The IPwstyle option mands (e.g. \Large, \sf). defines the corresponding environments. Compared with the approach of Hohti and Kan- erva mentioned above, our solution offers the follow- APL I~TEX document ing advantages: front end style option Several APL dialects are supported (currently Low symbol symbol APL2, Dyalog APL, I-APL, Sharp APL, and construction APL.68000). level translation No additional fonts are required. formatting APL symbols for all IPT@ sizes and type styles High APL logical are available. level (1 language / document We provide support for automatic typesetting formatting elements elements of APL objects. Table 1: Layers of the Publishing System There are some disadvantages, however; they are higher TEX interpretation overhead and higher memory usage. 3 Typesetting APL Symbols 2 The APL Publishing System If using a few APL symbols in an ordinary doc- ument is all you need, you can forget about The APL publishing system consists of two parts, the APL front end. Simply adding the op- the APL front end and the IPWdocument style op- tion apl to your preferred IPT@ document style tion apl . sty which communicate via a carefully de- (e.g. \documentstyle [12pt ,apll {article)) en- signed interface of w macros (see Figure 1). This ables you to state in your paper, e.g.: ensures that both parts of the system can be modi- fied independently. By combining the simple APL symbols 0 and * we obtain the compound symbol @. Each of these modules is composed of two layers (see Table 1). The main task of the low level for- The code to produce this statement is: TUGboat, Volume 11 (1990), No. 4 \begin{quot at ion) \APLcirclebar 8 By combining the simple \APL\ symbols \APLcircleslope 6) \APLcircle\ and \APLstar\ we obtain the \APLcirclestar 0 compound symbol \APLcirclestar. \APLcirclestile @ \end(quot at ion) \APLdelstile T \APLdeltastile 4 In fact, you can typeset all simple and com- \APLdeltaunderbar -A pound symbols of APL2, as we have defined macros \APLdelt ilde 6' for all of them. Tables 2 and 3, respectively, show \APLdieresisdot them together with their macro names. \APLdowncarettilde Y \APLdowntackj ot h \APLnotgreater 5 \APLdowntackuptack I \APLnotless 2 \APLepsilonunderbar -E \APLomega w - - \APLequalunderbar - \APLoverbar \APLiotaunderbar -2 \APLplus + \APLleftbracketrightbracket 0 \APLquad 0 \APLquaddivide \APLquery ? El I \APLquadj ot \APLquote I3 \APLquadquote \APLrho P I3 \APLquadslope \APLrightarrow + m \APLrightbracket 1 \APLquotedot ! \APLslashbar f \APLrightparen \APLrightshoe 3 \APLslopebar t \APLupcarettilde 791 \APLsemicolon 7 \APLslash 1 \APLupshoejot f3 7P \APLslope \ \APLuptackjot \APLstar * Table 3: Compound APL2 Symbols \APLS~ile I \APLt ilde N \APLt imes x names. All macro names start with the \APL pre- \APLunderbar - fix, followed by the name of the symbol used in the \APLuparrow t APL literature. The symbol names for APL2 char- \APLupcaret A acters are taken from [IBM 851. For those characters \APLupshoe n (cf. Table 4) which are not included in the IBM list \APLupstile r we have invented consistent names. We always use \APLuptack T symbol names, not the name of APL functions these symbols might represent. The name of a compound APL symbol is the concatenation of the names of Table 2: Simple APL2 Symbols the simple APL symbols it is created from. As can be seen in Figure 2 which shows the IBM was the first company to implement APL character set (the atomic vector UAV) of APL2, not but it did not remain the only one. Companies such all APL characters are fancy symbols, and the lan- as I. P. Sharp and Dyadic Systems have produced guage uses ordinary alphanumeric characters as well. their own versions of the language. These and other To allow for a clean interface between the APL front companies, however, introduced only a few symbols end and the I4m part of our system, we decided not found in APL2. We have added twenty addi- to define macros for these characters as well. Their tional symbols to the APL2 character set to sup names are constructed as follows: port typesetting Dyalog APL, I-APL, Sharp APL, and APL.68000 (see Table 4). Each macro name starts with \APL. As you have probably guessed from the names For each letter we append the upper or in Tables 2, 3, and 4 we stick to a naming convention lowercase letter, if the letter is underlined we in order to minimize name clashes with other macro prefix the letter with "u". packages and also help users remembering the macro Capital letters: \APLA, . , \APLZ. TUGboat, Volume 11 (1990), No. 4 \APLdieresiscircle o \APLdieresisdel 0 \APLdieresis jot o \APLdieresisstar -k \APLdieresistilde ,-d \APLdieresisuptack T \APLlef ttack k \APLnot equalunderbar $ \APLquaddownarrow [5] \APLquadlef tarrow \APLquadrightarrow \APLquaduparrow [TI \APLrighttack -1 \APLstilebar t \APLtheta 6' Figure 2: The Atomic Vector of APL2 Table 4: Symbols Used in APL Dialects 4 Typesetting APL Objects Lowercase letters: \APLa, . , \APLz. Typing the name of an occasional APL symbol Underlined capital letters: \APLuA, . , within a normal text is not a real nuisance to the \APLuZ. author of APL texts. But typesetting a larger piece Underlined lowercase letters: \APLua, . , of APL code certainly is. Imagine a function named \APLuz. ATREE, which implements a recursive tree traver- For numbers we simply append their names: sal algorithm: \APLzero, . , \APLnine. V Z + CLASS-LIST A TREE ROOT ; The tiny numbers in the atomic vector of Fig- DEPTH; LIST ;I; RECLIST ; SUPERCLASS ure 2 correspond to positions for which no print- [l] Zt,CROOT able characters are defined by APL2. In case the 121 -+ ( v / ( , CROOT) - "CLASS-LIST) / APL front end encounters a non rintable charac- CYCLIC ter, e.g. the one at position 20 in 6AV, it generates [31 It2 OTF~~GET-MEM'ACLASS1( \APLmiss<ZO). The definition of the macro ROOT. ' . SUPERCLASS ' ) \APLmiss determines the printed representation of [41 -+((opcip' 'I--SUPERCLASS)/O this character (the default macro in our style just [51 It ( CCLASS-LIST, CROOT) ATREE" prints the corresponding number in style \tiny). SUPERCLASS Let us close this section with one more example 161 z+( (ZZZ)=zpz) lz+z, T ,I,",I of typesetting APL symbols: [71 +o [81 CYCLIC:ZC0pO \APLquaddivide\APLA\ corresponds to V $AA<-I>$ in mathematical notation and \APLcircleslope\APLA\ corresponds In order to print just the beginning of the to $AeITI$. header of the function, you would have to type: displays as: A corresponds to A-' in mathematical nota- tion and 6)A corresponds to AT. 648 TUGboat, Volume 11 (1990), No. 4 \APLT\APLR\APLE\APLE% In the following we present examples for each of \APLbr\APLspace\APLR\APLO\APLO\APLT\APLb the cases mentioned above. At the same time, the examples give us the opportunity to demonstrate Obtaining the familiar function layout used Mriations of type style and size. in APL textbooks would require additional code. What is more, besides being awkward the whole pro- 4.1 Typesetting APL Arrays cess is error-prone: Almost certainly it will result in a printout different from the APL code. The interpreter usually displays arrays as text ma- Therefore we strongly recommend automatic trices on the screen. For example, the matrix X is translation of APL code. We provide an APL front displayed as: end which transforms APL objects into logical docu- ment elements which can be \input into IPWdoc- uments. This guarantees consonance between the original APL code and its listing and is also more convenient. The above printout is typeset by the following For all APL language elements we have defined code which is automatically produced by the APL APL functions and corresponding IPW environ- front end: ments. Our system supports the typesetting of: an array displayed by the interpreter, an array in boxed representation, 0 a function or operator displayed by the built in APL del-editor ( V-editor), a function or operator displayed by APL's canonical representation function UCR, a direct definition of a function or operator, 0 an APL expression input by the user.