lout-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mark Shields' equation formatting stuff


From: Jeff Kingston
Subject: Mark Shields' equation formatting stuff
Date: Wed, 05 May 1999 16:18:34 +1000

Over one year ago now Mark Shields produced quite a lot of stuff,
including enhancements to the Lout interpreter, with the aim of
getting equation formatting up to TeX quality.  I've never yet
had time to seriously evaluate his stuff but I am beginning now.

Here is what he sent me at the time.  You can download it all from
his web site (now http://www.cse.ogi.edu/~mbs/) - I've just done
this myself but have not tried to install yet, in any case it
was done off 3.11 - but the mail below seems to be a good summary
of the changes he made.

I'm against the syntax changes (^, _, $$) because I think they
are foreign to Lout's style.  But there is a lot more in Mark's
proposal than a few syntax changes.  What do people think of it?

Jeff
---------------------------------------------------------------------
>From address@hidden Tue Mar 24 10:05:18 1998
Received: by staff.cs.usyd.edu.au with postie; Tue, 24 Mar 1998 10:05:18 +1000
Received: from vanuata.dcs.gla.ac.uk. by staff.cs.usyd.edu.au.; Tue, 24 Mar 
1998 10:05:12 +1100
X-Claimed-Received: from vanuata
Received: from emae by vanuata with SMTP (MMTA);
          Mon, 23 Mar 1998 23:03:46 +0000
From: Mark Shields <address@hidden>
Organisation: University of Glasgow (Department of Computing Science)
To: Jeff Kingston <address@hidden>
Subject: Lout @Eq Package
X-Mailer: VM 6.34 under Emacs 19.34.6
PP-Warning: No Date field - one added at vanuata.dcs.gla.ac.uk
Date: Mon, 23 Mar 1998 23:05:01 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"

Hi Jeff, 

I've put together a replacement for your @Eq package which uses BlueSky's
Postscript Computer Modern, AMS Symbols and Euler fonts, and which tries 
very hard to follow TeX's math mode layout rules as closely as possible. 
I switched to BlueSky's fonts as they seem to have the best metrics of the
three available Postscriptized CM fonts, and I decided to try and replicate
TeX's rules once I realised just how important they were to good looking
type.

The good news is that for input almost as concise as in TeX we get output
almost as TeX itself would produce. Scripts, limits, fractions, accents,
overlines, overbraces, style changes and of course all the symbols are
very close to what TeX produces. Combined scripts, radicals and consecutive
binary/relational operators don't work as nicely as in TeX, but are 
easy to manually adjust.

The bad news is:
 - It's slower than the original @Eq package.
 - It is not compatible with your original two @Eq packages.
 - I've had to make quite a few changes to the lout interpreter itself.

Most of the changes are in z06.c, z08.c and z37.c, but there are many
smaller changes scattered throughout the other C files, makefile, 
dosetup, dl and master files. The new files are:
   include/louteq      - main package
   include/louteqfonts - font defs
   include/louteqascii - ascii symbol defs
   doc/louteq/         - A document enumerating all the symbols and 
                         combinators, and demonstrating a few of the 
                         TeXBook math mode challenges (which are easy 
                         in lout, of course!)
   doc/makemetrics/    - A lout document which calculates the metric 
                         information needed by the louteq package and 
                         produces a series of lout definitions as output. 
                         Basically, we partially evaluate as much of the
                         maths need by @Eq as possible.  
   setup/detreport     - as for dreport, but also includes louteq, tab & diag
   maps/*              - map files for the new fonts
   installfonts        - script to install the CM and AMS fonts in the
                         right places.

At this stage I'd like to typeset a few papers of my own using the
package before I give it a public release, but I thought it would be
good to get in contact with you now. I'm hoping you will be willing to
eventually incorporate this package and all or most of the interpreter 
changes into the mainline lout system (I branched off version 3.11), but 
I'll understand if you find some of the changes contentious. In particular,
"_" is now a delimiter, and "_", "^" and "$" have special significance to
the parser, so this breaks existing documents. 

Of course I may well have made some poor design decisions along the way 
and there is a better way of doing what we need without so many changes.

The revised installation tar file is available from:
   http://www.dcs.gla.ac.uk/~mbs/src/
To avoid any confusion, I have (somewhat tongue-in-cheek) called this 
version of the interpreter "louteq", and made the appropriate changes to
the version string and usage.

I hope you'll have a chance to take a look at what I've done. Any feedback
would be most welcome at this early stage.

I append the header from the louteq file.

Regards,
Mark

###############################################################################
#                                                                             #
# louteq - An equation formatting package closer to TeX and LaTeX than        #
#          the standard Lout eq and teq packages.                             #
#                                                                             #
# --------------------------------------------------------------------------- #
#       WARNING: Requires the louteq extended interpreter - see below         #
# --------------------------------------------------------------------------- #
#                                                                             #
#  eq     Version 2.0 by Jeffrey H. Kingston, 22 December 1992.               #
#  teq    Versions 1.0 and 1.1 by Jeffrey H. Kingston, 10 April 1995          #
#  teq    Version 2.0 by Jeffrey H. Kingston, April 1996 (based on @Eq 3.07). #
#  teq    Version 2.1 by Jeffrey H. Kingston, 8 September 1996.               #
#  teq    Version 2.2 by Jeffrey H. Kingston, 1 December 1996.                #
#  louteq Version 0.1 by Mark B. Shields, 17 March 1998.                      #
#                                                                             #
# Features:                                                                   #
#  - Uses the BlueSky (AMS licensed) Computer Modern, AMS symbol and Euler    #
#    fonts. Does not rely on any glyphs from the Adobe Symbol font.           #
#  - Follows the font metrics as much as possible. Most of the constants in   #
#    this file were derived by makemetrics from the TeX fontparams encoded as #
#    comments in the font metric files, and from the character metrics        #
#    themselves.                                                              #
#  - Follows TeX, LaTeX and AMSTeX's symbol names.                            #
#  - Implements TeX style superscripts, subscripts, fractions, limits,        #
#    accents, under/over line/brace, and operator spacing. Currently combined #
#    superscripts and subscripts, radicals, and consecutive operator spacing  #
#    only approximate TeX's rules.                                            #
#  - Uses TeX's eight styles, and the rules for switching between them, to    #
#    control spacing and font sizes.                                          #
#  - Automatic italic correction for superscripts and subscripts.             #
#  - Automatic italic correction for accents.                                 #
#  - ^ and _ behave as in TeX, except that ^^ and __ must be used for big     #
#    operator limits.                                                         #
#  - $x$ behaves as in TeX, though @DE{x} should be used instead of $$x$$.    #
#  - Each equation may choose a font scheme. Currently Computer Modern,       #
#    Euler Fractur and Euler Math are supported.                              #
#  - Normal, Bold and Italic face changes apply to all symbols, though some   #
#    families don't distinguish Bold and/or Italic from Base.                 #
#  - Big operator sizes depend on display or text mode.                       #
#  - Naming convention is for symbols and essential combinators (such as      #
#    over) to be unescaped and lowercase, formatting commands (such as @RM)   #
#    to be @ escaped and capitalized.                                         #
#  - includes a simple-minded deduction combinator. Not as good as Paul       #
#    Taylor's prooftree TeX package though.                                   #
#                                                                             #
# Quirks:                                                                     #
#  - "." is mapped to "period" in the symbol font, which has the character    #
#    code for ":" in the math italic (ie the ambient) font. If you encounter  #
#    an error with a length or position containing a ":", then simply quote   #
#    the offending string. It's a good idea to quote all lengths as a matter  #
#    of course.                                                               #
#  - The argument to @RM, etc, will be parsed in the outermost scope, where   #
#    only top-level definitions will be visible. This means most text needn't #
#    be escaped, but unfortunately local names, such as column names in       #
#    row definitions, will not be visible. Use @EqRM in this case, and        #
#    remember to escape all symbol names.                                     #
#  - Unlike TeX, a binary or relational operator in display style will always #
#    be surrounded by space. Use @Rel { @Non x @Non y } to abut two relation  #
#    symbols, etc.                                                            #
#  - A combined super/sub script where the superscript has a descender and    #
#    subscript an ascender may not typeset correctly - place a small space    #
#    under the superscript to lift it out of harm's way.                      #
#  - A radical with a tall root and short body may not typeset correctly -    #
#    place a strut in the body to lift the radical overline to meet the       #
#    top of the radical.                                                      #
#  - Unlike TeX, ^ and _ will always set super/sub scripts, even on big       #
#    operators, and ^^ and __ will always set limits, even on big operators   #
#    in text style.                                                           #
#  - Unlike TeX, a big operator does not include a surrounding @HardThinGap.  #
#    This makes super and subscripts typeset correctly, but means you must    #
#    remember to add the space manually.                                      #
#                                                                             #
# Still to do:                                                                #
#  - wrapper around @Diag package for simple commuting diagrams.              #
#  - variable sized delimiters without using @VScale. Need a combined         #
#    operator which will equally scale the delimiter bar, and then place the  #
#    top, scaled bar, middle, scaled bar and bottom glyphs above each other.  #
#  - capture TeX font parameters from comments in metrics file.               #
#  - font scheme dependent metrics? How?                                      #
#  - safe eager: issue warning when an eagerly manifested object tries to     #
#    split. Currently an assertion within CopyObject fails.                   #
#  - refined version of outermost modifier.                                   #
#                                                                             #
###############################################################################

###############################################################################
#                                                                             #
# Louteq Extensions                                                           #
#                                                                             #
# Here's what you get in the louteq extended interpreter. Most of these       #
# have been exploited in the louteq package, though most are not specific to  #
# math typesetting. My hope is that these extensions will be merged into the  #
# standard lout distribution.                                                 #
#                                                                             #
#  1. In fontdef implementation specific section or @Font lhs, the following  #
#     keywords may appear:                                                    #
#       NoXHeightAdjust   - don't shift the origin up by half the font's      #
#                           X height.                                         #
#       XHeightAdjust     - default.                                          #
#       NoItalicCor       - don't add a character's italic correction to      #
#                           its width when it appears at the end of a word.   #
#       PosItalicCor      - default. Add only if positive.                    #
#       AnyItalicCor      - Always add.                                       #
#     These options are required because the CM extensibles and other         #
#     fonts have encoded some extra information in their font metrics. The    #
#     italic correction encodes:                                              #
#       -ve italic cor    - character is upright, and both superscripts       #
#                           and subscripts should be tucked in by the         #
#                           correction amount.                                #
#       +ve italic cor    - character is sloped, and only subscripts should   #
#                           be tucked in.                                     #
#     For surd and the big delimiters:                                        #
#       character height  - is the width of an overline to continue the       #
#                           delimiter/surd.                                   #
#     And for everything in the CM Extensibles font:                          #
#       x height          - is that of the CM math italic font and should be  #
#                           ignored.                                          #
#                                                                             #
#  2. In a @Font command, CurrentFace designates the current face name. This  #
#     allows a family change to preserve the current face, but will fail if   #
#     the family has no such face.                                            #
#                                                                             #
#  3. The following commands may be used to find the size of a word or        #
#     series of words, but are not intended for composite objects:            #
#       @WordXHeight   x   - X height of font of x                            #
#       @WordHeight    x   - Height of x, may be -ve                          #
#       @WordDepth     x   - Depth of x, may be -ve                           #
#       @WordFwd       x   - Forward length of x                              #
#       @WordBack      x   - Backward length of first word in x, may be -ve   #
#       @WordItalicCor x   - Italic correction of last word in x, may be -ve  #
#     Also:                                                                   #
#       x @KernLength y                                                       #
#     finds the kern correction between the last char in the last word in x,  #
#     and the first char of the first word of y.                              #
#                                                                             #
#  4. x^y, x_z and x^y_z or x_z^y are replaced with x sup sup {y},            #
#     x sub sub {z} and x supsub sup {y} sub {z}. ^ and _ are non             #
#     associative and have highest precedence. sup, sub and supsub must       #
#     be in scope and have the correct argument names.                        #
#                                                                             #
#  5. Similarly, x^^y, x__z and x^^y__z or x__z^^y are replaced with          #
#     x suplimit sup {y}, x sublimit sub {z} and                              #
#     x supsublimit sup {y} sub {z}.                                          #
#                                                                             #
#  6. $x$ is replaced with @Eq { x }, and we take care to parse x in the      #
#     scope of @Eq's exported definitions.                                    #
#                                                                             #
#  7. The following commands implement primitive arithmetic and logical       #
#     operators. Arguments must be scalars or agree in their unit. Units      #
#     are preserved for arithmetic operations. The result will be an integer  #
#     where possible. Eg:                                                     #
#       "1f" @NPlus "2"  ==> "3f"                                             #
#       "1f" @NPlus "2z" ==> "??" (and warning emitted)                       #
#                                                                             #
#       x @NPlus y   - already in Lout (called @Plus), but not documented     #
#       x @NMinus y  - already in Lout (called @Minus), but not documented    #
#       x @NTimes y                                                           #
#       x @NDivide y - with division by zero check                            #
#       x @NCmp y    - "-1" if x < y, "0" if x == y, "1" otherwise            #
#       @NAbs x      - absolute value of x, without any sign                  #
#       @NRel x      - make x a relative length by adding a sign if required  #
#       @NScalar x   - make x a scalar value by removing any unit             #
#       x @LAnd y    - "1" if x and y are non-zero, "0" otherwise             #
#       x @LOr y     - "1" if x or y are non-zero, "0" otherwise              #
#       @LNot x      - "1" if x is zero, "0" otherwise                        #
#                                                                             #
#  8. x @Coerce y coerces x into units given by y, eg:                        #
#       { "9p" } @Font { "1f" @Coerce p } ==> "9p"                            #
#       "0.5f" @ZUnit { "1z" @Coerce f }  ==> "0.5f"                          #
#                                                                             #
#  9. @Echo x prints x to the console and yields the empty object.            #
#                                                                             #
# 10. The rhs of @Case expressions may be an expression which evaluates to a  #
#     single word containing a sequence of key/value pairs in the form:       #
#         (key,value)                                                         #
#     The value corresponding to the leftmost key matching the case tag will  #
#     be returned. Eg:                                                        #
#         "2" @Case "(1,one)(2,two)(3,three)" ==> three                       #
#     This is very much more efficient than the usual case rhs, but can only  #
#     be used to map words to words.                                          #
#                                                                             #
# 11. The introduction of named parameters, left and right parameters and     #
#     definitions may be followed by the keyword "eager" to force evaluation  #
#     of the argument or definition when their containing closure is entered. #
#     Eg:                                                                     #
#       def eager @TwoPi { @Pi @NTimes "2" }                                  #
#       def something                                                         #
#           left eager x                                                      #
#           named a { }                                                       #
#           named eager b { }                                                 #
#           right y                                                           #
#       { ... }                                                               #
#                                                                             #
#     This is useful for length calculations, but should not be used on       #
#     arbitrary objects, nor top level definitions.                           #
#                                                                             #
# 12. The introduction of a body parameter may be followed by the keyword     #
#     "outermost". It's arguments will then be parsed in the outermost scope  #
#     of the program, ie, only top-level definitions will be in scope.        #
#     This is exploited by @RM, etc, to suppress all @Eq keywords within      #
#     their body:                                                             #
#        def @RM body outermost x { ... x ... }                               #
#                                                                             #
#     This feature is experimental - a more refined method would be to        #
#     specify which symbol's outer scope to move to, eg:                      #
#        def @RM body outerof @Eq x { ... x ... }                             #
#     will make all definitions of @Eq disappear. But what if a address@hidden 
scope #
#     is between two @Eq scopes and it depends on @Eq? It's not at all clear  #
#     what the semantics of such a construct should be.                       #
#                                                                             #
# 13. Duplicate font metric kern entries are (silently) ignored. This is so   #
#     we can use the BlueSky fonts out-of-the-box.                            #
#                                                                             #
###############################################################################




reply via email to

[Prev in Thread] Current Thread [Next in Thread]