home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / tex / cstex / disk1 / cstexdoc.lzh / TEX_DOC / KNUTH.DOC < prev    next >
Encoding:
Text File  |  1989-11-02  |  17.5 KB  |  337 lines

  1. **********************************************************************
  2. *            The new versions of TeX and Metafont:                   *
  3. *                      Draft description                             *
  4. **********************************************************************
  5. by Donald E. Knuth
  6.  
  7. For more than five years I held firm to my conviction that a stable
  8. system was far better than a system that continues to evolve. But
  9. during the TUG meeting at Stanford in August, 1989, I was persuaded to
  10. make one last set of changes, in order to bring TeX and Metafont to a
  11. state of completion consistent with their overall philosophy and
  12. goals.
  13.  
  14. The main reason for the changes was the fact that I had guessed wrong
  15. about 7-bit character sets versus 8-bit character sets. I believed
  16. that standard text input would continue indefinitely to be confined to
  17. at most 128 characters, since I did not think a keyboard with 256
  18. different outputs would be especially efficient. Needless to say, I
  19. was proved wrong, especially by developments in Europe and Asia. As
  20. soon as I realized that a text formatting program with 7-bit input
  21. would rapidly begin to seem as archaic as the 6-bit systems we once
  22. had, I knew that a fundamental revision was necessary.
  23.  
  24. But the 7-bit assumption pervaded everything, so I needed to take the
  25. programs apart and redo them thoroughly in 8-bit style. This put TeX
  26. onto the operating table and under the knife for the first time since
  27. 1984, and I had a final opportunity to include a few new features that
  28. had occurred to me or been suggested by users since then.
  29.  
  30. The new extensions are entirely upward compatible with previous
  31. versions of TeX and Metafont (with a few small exceptions mentioned
  32. below). This means that error-free inputs to the old TeX and Metafont
  33. will still be error-free inputs to the new systems, and they will
  34. still produce the same outputs.
  35.  
  36. However, anybody who dares to use the new extensions will be unable to
  37. get the desired results from old versions of TeX and Metafont. I am
  38. therefore asking the TeX community to update all copies of the old
  39. versions as soon as possible. Let us root out and destroy the obsolete
  40. 7-bit systems, even though we were able to do many fine things with
  41. them.
  42.  
  43. In this note I'll discuss the changes, one by one; then I'll describe
  44. the exceptions to upward compatibility.
  45.  
  46. 1. The character set.
  47.  
  48.    Up to 256 distinct characters are now allowed in input files. The
  49.    codes that were formerly limited to the range 0...127 are now in
  50.    the range 0...255. All characters are alike; you are free to use
  51.    any character for any purpose in TeX, assigning appropriate values
  52.    to its \catcode, \mathcode, \lccode, \uccode, \sfcode, and
  53.    \delcode. Plain TeX initializes these code values for characters
  54.    above 127 just as it initializes the codes for ordinary punctuation
  55.    characters like "!".
  56.  
  57.    There's a new convention for inputting an arbitrary 8-bit character
  58.    to TeX when you can't necessarily type it: The four consecutive
  59.    characters  ||xy, where x and y are any of the "lowercase
  60.    hexadecimal digits"  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e,
  61.    or f, are treated by TeX on input as if they were a single
  62.    character with specified code digits. For example,  ||80 gives
  63.    character code 128; the entire character set is available from ||00
  64.    to ||ff. The old convention discussed in Appendix C, under which
  65.    character 0 was ||@, character 1 (control--A) was ||A, ..., and
  66.    character 127 was ||?, still works for the first 128 character
  67.    codes, except that the character following || should not be a
  68.    lowercase hexadecimal digit when the immediately following
  69.    character is another such digit.
  70.  
  71.    The existence of 8-bit characters has less effect in Metafont than
  72.    in TeX, because Metafont's character classes are built in to each
  73.    installation. The normal set of 95 printing characters described on
  74.    page 51 of  Metafontbook can be supplemented by extended characters
  75.    as discussed on page 282, but this is rarely done because it leads
  76.    to problems of portability. Metafont's  char operator is now
  77.    redefined to operate modulo 256 instead  of modulo 128.
  78.  
  79. 2. Hyphenation tables.
  80.    Up to 256 distinct sets of rules for hyphenation are now allowed in
  81.    TeX. There's a new integer parameter called \language, whose
  82.    current value specifies the hyphenation convention in force. If
  83.    \language is negative or greater than 255, TeX acts as if
  84.    \language=0.
  85.  
  86.    When you list hyphenation exceptions with TeX's  \hyphenation
  87.    primitive, those exceptions apply to the current language only.
  88.    Similarly, the \patterns primitive tells TeX to remember new
  89.    hyphenation patterns for the current language; this operation is
  90.    allowed only in the special "initialization" program called
  91.    INITEX. Hyphenation exceptions can be added at any time, but new
  92.    patterns cannot be added after a paragraph has been typeset.
  93.  
  94.    When TeX reads the text of a paragraph, it automatically inserts
  95.    "whatsit nodes" into the horizontal list for that paragraph
  96.    whenever a character comes from a different \language than its
  97.    predecessor. In that way TeX can tell what hyphenation rules to use
  98.    on each word of the paragraph even if you switch  frequently back
  99.    and forth among many different languages.
  100.  
  101.    The special whatsit nodes are inserted automatically in
  102.    unrestricted horizontal mode (i.e., when you are creating a
  103.    paragraph, but not when you are specifying the contents of an
  104.    hbox). You can insert a special whatsit yourself in restricted
  105.    horizontal mode by saying \language<number>. This is needed only if
  106.    you are doing something tricky, like unboxing some contribution to
  107.    a paragraph.
  108.  
  109. 3. Hyphenated fragment control.
  110.    TeX has new parameters  \lefthyphenmin and \righthyphenmin, which
  111.    specify the smallest word fragments that will appear at the
  112.    beginning or end of a word that has been hyphenated. Previously the
  113.    values \lefthyphenmin=2 and \righthyphenmin=3 were hard-wired into
  114.    TeX and impossible to change. Now plain TeX  format supplies the
  115.    old values, which are still recommended for most American
  116.    publications; but you can get more hyphens by decreasing these
  117.    parameters, and you can get fewer hyphens by increasing them. If
  118.    the sum of \lefthyphenmin and \righthyphenmin is 63 or more, all
  119.    hyphenation is suppressed. (You can also suppress  hyphenation by
  120.    using a font with \hyphenchar=-1, or by switching to a  \language
  121.    that has no hyphenation patterns or exceptions.)
  122.  
  123. 4. Smarter ligatures.
  124.    Now here's the most radical change. Previous versions of TeX had
  125.    only one kind of ligature, in which two characters like "f" and "i"
  126.    were changed into a single character like "fi" when they appeared
  127.    consecutively. The new TeX understands much more complex
  128.    constructions by which, for example, we could change an "i"
  129.    following "f" to a dotless "\i" while the "f" remains unchanged:
  130.    "f\i".
  131.  
  132.    As before, you get ligatures only if they have been provided in the
  133.    font you are using. So let's look at the new features of Metafont
  134.    by which enhanced ligatures can be created. A Metafont programmer
  135.    can specify a "ligature/kerning program" for any character of the
  136.    font being created. If, for example, the "fi" combination appears
  137.    in font position 12, the replacement of "f" and "\i" by "fi" is
  138.    specified by including the statement "i" =: 12 in the
  139.    ligature/kerning program for "f"; this is Metafont's present
  140.    convention.
  141.  
  142.    The new ligatures allow you to retain one or both of the original
  143.    characters while inserting a new one. Instead of =: you can also
  144.    write |=: if you wish to retain the left character, or =:| if you
  145.    wish to retain the right character, or |=:| if you want to keep
  146.    them both. For example, if the dotless \i appears in font position
  147.    16, you can get the behavior mentioned above by having "i" |=: 16
  148.    in f's program.
  149.  
  150.    There also are four additional operators |=:>,  =:|>,  |=:|>,
  151.    |=:|>>, where each > tells TeX to shift its focus one position to
  152.    the right. For example, if f and i had been replaced by f and
  153.    dotless \i as above, TeX would begin again to execute f's
  154.    ligature/kern program, possibly inserting a kern before the dotless
  155.    \i, or possibly changing the f to an entirely different character,
  156.    etc. But if the instruction had been "i" |=:> 16 instead, TeX would
  157.    turn immediately to the ligature/kern program for characters
  158.    following character 16 (the dotless \i); no further change would be
  159.    made between f and \i even if the font had something specified
  160.    there.
  161.  
  162. 5. Boundary ligatures.
  163.    Every consecutive string of "characters" read by TeX in horizontal
  164.    mode (after macro expansion) can be called a "word". (Technically
  165.    we consider a "character" in this definition to be either a
  166.    character whose \catcode is a letter or otherchar, or a control
  167.    sequence that has been \let equal to such a character, or a control
  168.    sequence that has been defined by \chardef, or the construction
  169.    \char<number>.) The new TeX now imagines that there is an invisible
  170.    "left boundary character" just before every such word, and an
  171.    invisible "right boundary character" just after it. These boundary
  172.    characters take effect if the font designer has specified ligatures
  173.    and/or kerning between them and the adjacent letters. Thus, the
  174.    first or last character of a word can  now be made to change its
  175.    shape automatically.
  176.  
  177.    A ligature/kern program for the left boundary character is
  178.    specified within Metafont by using the special label  ||: in a
  179.    ligtable command. A ligature or kern with the right boundary
  180.    character is specified by assigning a value to the new internal
  181.    Metafont parameter  boundarychar, and by specifying a ligature or
  182.    kern with respect to this character. The boundarychar may or may
  183.    not exist as a real character in the font.
  184.  
  185.    For example, suppose we want to change the first letter of a word
  186.    from "F" to "ff" if we are doing some olde English. The Metafont
  187.    font designer could then say ligtable ||: "F" |:= 11 if character
  188.    11 is the "ff". The same ligtable instruction should appear in the
  189.    programs for characters like ( and ` and " and - that can precede
  190.    strings of letters; then "Bassington-French" will yield
  191.    "Bassington-ffrench".
  192.  
  193.    If the "s" of our font is the pre-19th century s that looks like a
  194.    mutilated "f", and if we have a modern "s" in position 128, we can
  195.    convert the final s's as Ben Franklin did by introducing ligature
  196.    instructions such as
  197.  
  198.             boundarychar := 255;
  199.             ligtable "s":   255 =:| 128,
  200.                             "." =:| 128,
  201.                             "," =:| 128,
  202.                             ")" =:| 128,
  203.                             "'" =:| 128,
  204.    and so on. (A true oldstyle font would also have ligatures for ss
  205.    and si and sl and ssi and ssl and st; it would be fun to create a
  206.    Computer Modern Oldstyle.)
  207.  
  208.    The implicit left boundary character is omitted by TeX if you say
  209.    \noboundary just before the word; the implicit right boundary is
  210.    omitted if you say \noboundary just after it.
  211.  
  212. 6. More compact ligatures.
  213.    Two or more ligtables can now share common code. To do this in
  214.    Metafont, you say "skipto <n>" at the end of one ligtable command,
  215.    then you say "<n>::" within another. Such local labels can be
  216.    reused; e.g., you can say skipto 1 again after 1:: has appeared,
  217.    and this skips to the _next_ appearance of 1::. There are 256 local
  218.    labels, numbered 0 to 255. Restriction: At most 128 ligature or
  219.    kern commands can intervene between a skipto and its matching
  220.    label.
  221.  
  222.    The TFM file format has been upwardly extended to allow more than
  223.    32,500 ligature/kern commands per font. (Previously there was an
  224.    effective limit of 256.)
  225.  
  226. 7. Better looking sloppiness.
  227.    There is now a better way to avoid overfull boxes, for people who
  228.    don't want to look at their documents to fix unfeasible line breaks
  229.    manually. Previously people tried to do this by setting
  230.    \tolerance=10000, but the result was terrible because TeX would
  231.    tend to consolidate all the badness in one truly horrible line.
  232.    (TeX considers all badness >=10000 to be infinitely bad, and all
  233.    these infinities are equal.)
  234.  
  235.    The new feature is a dimension parameter called \emergencystretch.
  236.    If \emergencystretch is positive and if TeX has been unable to
  237.    typeset a paragraph without exceeding the given tolerances, another
  238.    pass over the paragraph is made in which TeX pretends that
  239.    additional stretchability equal to \emergencystretch is present in
  240.    every line. The effect of this is to scale down all the badnesses
  241.    into a range where previously infinite cases become finite;  TeX
  242.    will find an optimum solution to the scaled-down problem, and this
  243.    will be about as good as possible in a practical sense. (The extra
  244.    stretching is not really present; therefore underfull boxes will be
  245.    reported in warning messges unless \hbadness is increased.)
  246.  
  247. 8. Looking at badness.
  248.    TeX has a new internal integer parameter called \badness that
  249.    records the badness of the box it has most recently constructed. If
  250.    that box was overfull, \badness will be 1000000; otherwise \badness
  251.    will be between 0 and 10000.
  252.  
  253. 9. Looking at the line number.
  254.    TeX also has a new internal integer parameter called \inputlineno,
  255.    which contains the number of the line that TeX would show on an
  256.    error message if an error occurred now. (This parameter and
  257.    \badness are "read only" in the same way as \lastpenalty: You can
  258.    use them in the context of a <number>, e.g., by saying
  259.    "\ifnum\inputlineno>\badness ...\ \fi" or "\the\inputlineno", but
  260.    you cannot set them to new values.)
  261.  
  262. 10. Not looking at error context.
  263.    There's a new integer parameter called \errorcontextlines that
  264.    specifies the maximum number of two-line pairs of context displayed
  265.    with TeX's error messages (in addition to the top and bottom lines,
  266.    which always appear). Plain TeX now sets \errorcontextlines=5, but
  267.    higher level format packages might prefer \errorcontextlines=1  or
  268.    even \errorcontextlines=0. In the latter case, an error that
  269.    previously involved three or more pairs of context would now appear
  270.    as follows:
  271.             ! Error.
  272.             <somewhere> The \top
  273.                         The \top\ line
  274.             ...
  275.             1.123 \The
  276.                   \The\ bottom line.
  277.    (If \errorcontextlines<0 you wouldn't even see the `...' here.)
  278.  
  279. 11. Output recycling.
  280.    One more new integer parameter completes the set. If
  281.    \holdinginserts>0 when TeX is putting the current page into \box255
  282.    for the  \output routine, TeX will not move anything from insertion
  283.    nodes into the corresponding boxes; all insertion nodes will stay
  284.    in place. Designers of output routines can use this when they want
  285.    to put the contents of box 255 back into the current page to be
  286.    re-broken (because they might want to change \vsize or something).
  287.  
  288. 12. Exceptions to upward compatibility.
  289.    The new features of TeX and Metafont imply that a few things work
  290.    differently than before. I will try to list all such cases here
  291.    (except when the  previous behavior was erroneous due to a bug in
  292.    TeX or Metafont). I don't know of any cases where users will
  293.    actually be affected, because all of these exceptions are pretty
  294.    esoteric.
  295.  
  296.    o TeX used to convert the character strings ||0, ||1,..., ||9, ||a,
  297.      ||b, ||c, ||d, ||e, ||f into the respective single characters p,
  298.      q,..., y, !, ", #, $, %, &. It will no longer do this if the
  299.      following character is one of the characters 0123456789abcdef.
  300.  
  301.    o TeX used to insert no character at the end of an input line if
  302.      \endlinechar>127. It will now insert a character unless
  303.      \endlinechar>255. (As previously, \endlinechar<0 suppresses the
  304.      end-of-line character. This character is normally 13=ASCII
  305.      control--M = carriage return.)
  306.  
  307.    o Some diagnostic messages from TeX used to have the notation
  308.      ["80]...["FF] when referring to characters 128...255 (for example
  309.      when displaying the contents of an overfull box involving fonts
  310.      that include such characters). The notation ||80...||ff is now
  311.      used instead.
  312.  
  313.    o The expressions char128 and char0 used to be equivalent in
  314.      Metafont; now char is defined modulo 256 instead. Hence char-1 =
  315.      char255, etc.
  316.  
  317.    o INITEX used to forget all previous hyphenation patterns each time
  318.      you specified \patterns. Now all hyphenation pattern specifications
  319.      are cummulative, and you are not permitted to use \patterns after a
  320.      paragraph has been hyphenated by INITEX.
  321.  
  322.    o TeX used to act a bit differently when you tried to typeset
  323.      missing characters of a font. A missing character is now considered
  324.      to be a word boundary, so you will get slightly more diagnostic
  325.      output when \tracingcommands>0.
  326.  
  327.    o TeX and Metafont will report different statistics at the end of a
  328.      run because they now have a different number of primitives.
  329.  
  330.    o Programs that use the string pool feature of TANGLE will no
  331.      longer run without changes, because the new TANGLE starts numbering
  332.      multicharacter strings at 256 instead of 128.
  333.  
  334.    o INITEX programs must now set \lefthyphenmin=2 and
  335.      \righthyphenmin=3 in order to reproduce their previous behavior.
  336.  
  337. ə