diff --git a/doc/CONTRIBUTORS b/doc/CONTRIBUTORS
index b05b3c5a83563f888558a47430ad9cb3480dcf67..51bc75a724ab6e1bdb7f968e69c5bd159d00d7fc 100644
--- a/doc/CONTRIBUTORS
+++ b/doc/CONTRIBUTORS
@@ -1,9 +1,9 @@
-$Id: CONTRIBUTORS,v 1.26 2003-03-16 21:23:18 geuzaine Exp $
+$Id: CONTRIBUTORS,v 1.27 2003-04-15 06:38:55 geuzaine Exp $
 
 Gmsh is copyright (c) 1997-2003 by
 
-  Jean-Francois Remacle <remacle@@gce.ucl.ac.be> and
-  Christophe Geuzaine <geuzaine@@acm.caltech.edu>
+  Jean-Francois Remacle <remacle@gce.ucl.ac.be> and
+  Christophe Geuzaine <geuzaine@acm.caltech.edu>
 
 Portions of Gmsh are copyright (c)
 
@@ -16,17 +16,17 @@ This version of Gmsh may also contain code copyright (c) 1993, 1995,
 1997, 1998, 2002 Jonathan Richard Shewchuk: check the configuration
 options.
 
-Special thanks to David Colignon <David.Colignon@@univ.u-3mrs.fr> for
-new colormaps; Patrick Dular <patrick.dular@@ulg.ac.be> for transfinite
-mesh bug fixes; Laurent Stainier <l.stainier@@ulg.ac.be> for the Mac OS
+Special thanks to David Colignon <David.Colignon@univ.u-3mrs.fr> for
+new colormaps; Patrick Dular <patrick.dular@ulg.ac.be> for transfinite
+mesh bug fixes; Laurent Stainier <l.stainier@ulg.ac.be> for the Mac OS
 port and the tensor display code; Nicolas Tardieu
-<nicolas.tardieu@@edf.fr> and Pierre Badel <badel@@freesurf.fr> for help
-with the GSL integration and Marc Ume <Marc.Ume@@digitalgraphics.be>
+<nicolas.tardieu@edf.fr> and Pierre Badel <badel@freesurf.fr> for help
+with the GSL integration and Marc Ume <Marc.Ume@digitalgraphics.be>
 for the original list code.
 
-Special thanks also to Bill Spitzak <spitzak@@users.sourceforge.net>,
-Michael Sweet <easysw@@users.sourceforge.net>, Matthias Melcher
-<mm@@matthiasm.com> and others for the Fast Light Tool Kit on which
+Special thanks also to Bill Spitzak <spitzak@users.sourceforge.net>,
+Michael Sweet <easysw@users.sourceforge.net>, Matthias Melcher
+<mm@matthiasm.com> and others for the Fast Light Tool Kit on which
 Gmsh's GUI is based. See http://www.fltk.org for more info on this
 excellent object-oriented, cross-platform toolkit.
 
@@ -35,16 +35,16 @@ providing fresh ideas on theoretical or programming topics, who have
 sent patches, requests for changes or improvements, or who gave us
 access to exotic machines for testing Gmsh:
 
-  Juan Abanto <juanabanto@@yahoo.com>
-  Olivier Adam <o.adam@@ulg.ac.be>
-  Guillaume Alleon <guillaume.alleon@@airbus.aeromatra.com>
-  Eric Bechet <eric.bechet@@epost.de>
-  Laurent Champaney <laurent.champaney@@meca.uvsq.fr>
-  Pascal Dupuis <Pascal.Dupuis@@esat.kuleuven.ac.be>
-  Philippe Geuzaine <geuzaine@@gnat.colorado.edu>
-  Johan Gyselinck <johan.gyselinck@@ulg.ac.be>
-  Francois Henrotte <fhenrott@@esat.kuleuven.ac.be>
-  Benoit Meys <bmeys@@techspace-aero.be>
-  Nicolas Moes <moes@@tam9.mech.nwu.edu>
-  Osamu Nakamura <naka@@hasaki.sumitomometals.co.jp>
-  Chad Schmutzer <schmutze@@acm.caltech.edu>
\ No newline at end of file
+  Juan Abanto <juanabanto@yahoo.com>
+  Olivier Adam <o.adam@ulg.ac.be>
+  Guillaume Alleon <guillaume.alleon@airbus.aeromatra.com>
+  Eric Bechet <eric.bechet@epost.de>
+  Laurent Champaney <laurent.champaney@meca.uvsq.fr>
+  Pascal Dupuis <Pascal.Dupuis@esat.kuleuven.ac.be>
+  Philippe Geuzaine <geuzaine@gnat.colorado.edu>
+  Johan Gyselinck <johan.gyselinck@ulg.ac.be>
+  Francois Henrotte <fhenrott@esat.kuleuven.ac.be>
+  Benoit Meys <bmeys@techspace-aero.be>
+  Nicolas Moes <moes@tam9.mech.nwu.edu>
+  Osamu Nakamura <naka@hasaki.sumitomometals.co.jp>
+  Chad Schmutzer <schmutze@acm.caltech.edu>
\ No newline at end of file
diff --git a/doc/texinfo/geo2texi b/doc/texinfo/geo2texi
deleted file mode 100644
index b82c8f28d90ace4cacadb4fdb2bb8855861c97d7..0000000000000000000000000000000000000000
--- a/doc/texinfo/geo2texi
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-for file in  $*; do
-  echo modifying file $file...
-  echo "@format" > tmp.geo
-  echo "@code{" >> tmp.geo
-  sed -e "s|{|@{|g" -e "s|}|@}|g" $file >> tmp.geo
-  echo "}" >> tmp.geo
-  echo "@end format" >> tmp.geo
-  mv tmp.geo $file
-done
diff --git a/doc/texinfo/gmsh.texi b/doc/texinfo/gmsh.texi
index 733c95be095ef97ae44b1cbce449290012de057c..d7dc11abd6eb42be928449fe65ec340f2bbdc053 100644
--- a/doc/texinfo/gmsh.texi
+++ b/doc/texinfo/gmsh.texi
@@ -1,5 +1,5 @@
 \input texinfo.tex @c -*-texinfo-*-
-@c $Id: gmsh.texi,v 1.16 2003-04-15 05:12:01 geuzaine Exp $
+@c $Id: gmsh.texi,v 1.17 2003-04-15 06:38:55 geuzaine Exp $
 @c
 @c Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
 @c
@@ -76,15 +76,6 @@ Manual}, for Gmsh @value{GMSH-VERSION}.
 Copyright @value{COPYRIGHT}
 @end ifinfo
 
-@c =========================================================================
-@c TeX directives
-@c =========================================================================
-
-@iftex
-@global@let@sl=@it
-@global@setfont@indit@itshape{9}{1000}
-@end iftex
-
 @c =========================================================================
 @c Title page
 @c =========================================================================
@@ -1363,7 +1354,7 @@ formats. See @ref{File formats} for this.
 @node t1.geo, t2.geo, Tutorial, Tutorial
 @section @file{t1.geo}
 
-@include t1.geo
+@verbatiminclude ../../tutorial/t1.geo
 
 @c -------------------------------------------------------------------------
 @c t2.geo
@@ -1372,7 +1363,7 @@ formats. See @ref{File formats} for this.
 @node t2.geo, t3.geo, t1.geo, Tutorial
 @section @file{t2.geo}
 
-@include t2.geo
+@verbatiminclude ../../tutorial/t2.geo
 
 @c -------------------------------------------------------------------------
 @c t3.geo
@@ -1381,7 +1372,7 @@ formats. See @ref{File formats} for this.
 @node t3.geo, t4.geo, t2.geo, Tutorial
 @section @file{t3.geo}
 
-@include t3.geo
+@verbatiminclude ../../tutorial/t3.geo
 
 @c -------------------------------------------------------------------------
 @c t4.geo
@@ -1390,7 +1381,7 @@ formats. See @ref{File formats} for this.
 @node t4.geo, t5.geo, t3.geo, Tutorial
 @section @file{t4.geo}
 
-@include t4.geo
+@verbatiminclude ../../tutorial/t4.geo
 
 @c -------------------------------------------------------------------------
 @c t5.geo
@@ -1399,7 +1390,7 @@ formats. See @ref{File formats} for this.
 @node t5.geo, t6.geo, t4.geo, Tutorial
 @section @file{t5.geo}
 
-@include t5.geo
+@verbatiminclude ../../tutorial/t5.geo
 
 @c -------------------------------------------------------------------------
 @c t6.geo
@@ -1408,7 +1399,7 @@ formats. See @ref{File formats} for this.
 @node t6.geo, t7.geo, t5.geo, Tutorial
 @section @file{t6.geo}
 
-@include t6.geo
+@verbatiminclude ../../tutorial/t6.geo
 
 @c -------------------------------------------------------------------------
 @c t7.geo
@@ -1417,7 +1408,7 @@ formats. See @ref{File formats} for this.
 @node t7.geo, t8.geo, t6.geo, Tutorial
 @section @file{t7.geo}
 
-@include t7.geo
+@verbatiminclude ../../tutorial/t7.geo
 
 @c -------------------------------------------------------------------------
 @c t8.geo
@@ -1426,7 +1417,7 @@ formats. See @ref{File formats} for this.
 @node t8.geo, t9.geo, t7.geo, Tutorial
 @section @file{t8.geo}
 
-@include t8.geo
+@verbatiminclude ../../tutorial/t8.geo
 
 @c -------------------------------------------------------------------------
 @c t9.geo
@@ -1435,7 +1426,7 @@ formats. See @ref{File formats} for this.
 @node t9.geo,  , t8.geo, Tutorial
 @section @file{t9.geo}
 
-@include t9.geo
+@verbatiminclude ../../tutorial/t9.geo
 
 @c =========================================================================
 @c Running Gmsh
@@ -1849,11 +1840,11 @@ time (or any other variable) for which an evolution was saved.
 @item @var{vector-point-value}
 @item @dots{}
 are lists of double precision numbers giving the node coordinates and the
-values associated with the nodes of the @item @var{nb-scalar-points} scalar
-points, @item @var{nb-vector-points} vector points, @dots{}, for each
-of the @var{time-step-values}.
+values associated with the nodes of the @var{nb-scalar-points} scalar
+points, @var{nb-vector-points} vector points, @dots{}, for each of the
+@var{time-step-values}.
 
-For example, vector-triangle-value is defined as:
+For example, @var{vector-triangle-value} is defined as:
 @example
 @var{coord1-node1} @var{coord1-node2} @var{coord1-node3}
 @var{coord2-node1} @var{coord2-node2} @var{coord2-node3}
@@ -2265,9 +2256,7 @@ already know about.
 @cindex History, versions
 @cindex Changelog
 
-@example
-@include ../VERSIONS
-@end example
+@verbatiminclude ../VERSIONS
 
 @c -------------------------------------------------------------------------
 @c Contributors
@@ -2280,9 +2269,7 @@ already know about.
 @cindex Contributors, list
 @cindex Credits 
 
-@example
-@include ../CONTRIBUTORS
-@end example
+@verbatiminclude ../CONTRIBUTORS
 
 @end ifclear
 
diff --git a/doc/texinfo/t1.geo b/doc/texinfo/t1.geo
deleted file mode 100644
index 249ab54930c1c5c5ecb6a9b0f8a5d74937639172..0000000000000000000000000000000000000000
--- a/doc/texinfo/t1.geo
+++ /dev/null
@@ -1,109 +0,0 @@
-@format
-@code{
-/********************************************************************* 
- *
- *  Gmsh tutorial 1
- * 
- *  Variables, Elementary entities (Points, Lines, Surfaces), Physical
- *  entities (Points, Lines, Surfaces), Background mesh
- *
- *********************************************************************/
-
-// All geometry description in Gmsh is made by means of a special
-// language (looking somewhat similar to C). The simplest construction
-// of this language is the 'affectation'. 
-
-// The following command (all commands end with a semi colon) defines
-// a variable called 'lc' and affects the value 0.007 to 'lc':
-
-lc = 0.007 ;
-
-// This newly created variable can be used to define the first Gmsh
-// elementary entity, a 'Point'. A Point is defined by a list of four
-// numbers: its three coordinates (x, y and z), and a characteristic
-// length which sets the target mesh size at the point:
-
-Point(1) = @{0,  0,  0, 9.e-1 * lc@} ;
-
-// The mesh size is defined as the length of the segments for lines,
-// the radii of the circumscribed circles for triangles and the radii
-// of the circumscribed spheres for tetrahedra, respectively. The
-// actual distribution of the mesh sizes is obtained by interpolation
-// of the characteristic lengths prescribed at the points. There are
-// also other possibilities to specify characteristic lengths:
-// attractors (see t7.geo) and background meshes (see bgmesh.pos).
-
-// As can be seen in the previous definition, more complex expressions
-// can be constructed from variables. Here, the product of the
-// variable 'lc' by the constant 9.e-1 is given as the fourth argument
-// of the list defining the point.
-//
-// The following general syntax rule is applied for the definition of
-// all geometrical entities:
-//
-//    "If a number defines a new entity, it is enclosed between
-//    parentheses. If a number refers to a previously defined entity,
-//    it is enclosed between braces."
-//
-// Three additional points are then defined:
-
-Point(2) = @{.1, 0,  0, lc@} ;
-Point(3) = @{.1, .3, 0, lc@} ;
-Point(4) = @{0,  .3, 0, lc@} ;
-
-// The second elementary geometrical entity in Gmsh is the
-// curve. Amongst curves, straight lines are the simplest. A straight
-// line is defined by a list of point numbers. For example, line 1
-// starts at point 1 and ends at point 2:
-
-Line(1) = @{1,2@} ;
-Line(2) = @{3,2@} ;
-Line(3) = @{3,4@} ;
-Line(4) = @{4,1@} ;
-
-// The third elementary entity is the surface. In order to define a
-// simple rectangular surface from the four lines defined above, a
-// line loop has first to be defined. A line loop is a list of
-// connected lines, a sign being associated with each line (depending
-// on the orientation of the line).
-
-Line Loop(5) = @{4,1,-2,3@} ;
-
-// The surface is then defined as a list of line loops (only one
-// here):
-
-Plane Surface(6) = @{5@} ;
-
-// At this level, Gmsh knows everything to display the rectangular
-// surface 6 and to mesh it. But a supplementary step is needed in
-// order to assign region numbers to the various elements in the mesh
-// (the points, the lines and the triangles discretizing points 1 to
-// 4, lines 1 to 4 and surface 6). This is achieved by the definition
-// of Physical entities. Physical entities will group elements
-// belonging to several elementary entities by giving them a common
-// number (a region number), and specifying their orientation.
-//
-// For example, the two points 1 and 2 can be grouped into the
-// physical entity 1:
-
-Physical Point(1) = @{1,2@} ;
-
-// Consequently, two punctual elements will be saved in the output
-// files, both with the region number 1. The mechanism is identical
-// for line or surface elements:
-
-Physical Line(10) = @{1,2,4@} ;
-MySurface = 100;
-Physical Surface(MySurface) = @{6@} ;
-
-// All the line elements which will be created during the mesh of
-// lines 1, 2 and 4 will be saved in the output file with the region
-// number 10; and all the triangular elements resulting from the
-// discretization of surface 6 will be given the region number 100.
-//
-// If no physical groups are defined, all the elements in the mesh are
-// directly saved with their default orientation and with a region
-// number equal to their elementary region number. For a description
-// of the mesh and post-processing formats, see the reference manual.
-}
-@end format
diff --git a/doc/texinfo/t2.geo b/doc/texinfo/t2.geo
deleted file mode 100644
index 4b00e621861d7743e7d13a5908afdb1aad004eb9..0000000000000000000000000000000000000000
--- a/doc/texinfo/t2.geo
+++ /dev/null
@@ -1,90 +0,0 @@
-@format
-@code{
-/********************************************************************* 
- *
- *  Gmsh tutorial 2
- * 
- *  Includes, Geometrical transformations, Extruded geometries,
- *  Elementary entities (Volumes), Physical entities (Volumes)
- *
- *********************************************************************/
-
-// The first tutorial file will serve as a basis to construct this
-// one. It can be included with:
-
-Include "t1.geo" ;
-
-// There are several possibilities to build a more complex geometry
-// from the one previously defined in 't1.geo'.
-//
-// New points, lines and surfaces can first be directly defined in the
-// same way as in 't1.geo':
-
-Point(5) = @{0, .4, 0, lc@} ;
-Line(5) = @{4, 5@} ;
-
-// But Gmsh also provides geometrical transformation mechanisms to
-// move (translate, rotate, ...), add (translate, rotate, ...) or
-// extrude (translate, rotate) elementary geometrical entities. For
-// example, the point 3 can be moved by 0.05 units on the left with:
-
-Translate @{-0.05,0,0@} @{ Point@{3@} ; @}
-
-// The resulting point can also be duplicated and translated by 0.1
-// along the y axis:
-
-Translate @{0,0.1,0@} @{ Duplicata@{ Point@{3@} ; @} @}
-
-// Of course, translation, rotation and extrusion commands not only
-// apply to points, but also to lines and surfaces. The following
-// command extrudes surface 6 defined in 't1.geo', as well as a new
-// surface 11, along the z axis by 'h':
-
-h = 0.12 ;
-Extrude Surface @{ 6, @{0, 0, h@} @} ;
-
-Line(7) = @{3, 6@} ; Line(8) = @{6,5@} ; Line Loop(10) = @{5,-8,-7,3@};
-
-Plane Surface(11) = @{10@};
-
-Extrude Surface @{ 11, @{0, 0, h@} @} ;
-
-// All these geometrical transformations automatically generate new
-// elementary entities. The following commands permit to specify
-// manually a characteristic length for some of the automatically
-// created points:
-
-Characteristic Length@{6,22,2,3,16,12@} = lc * 2 ;
-
-// If the transformation tools are handy to create complex geometries,
-// it is sometimes useful to generate the flat geometry, consisting
-// only of the explicit list elementary entities. This can be achieved
-// by selecting the 'File->Save as->Gmsh unrolled geometry' menu or by
-// typing
-//
-// > gmsh t2.geo -0
-//
-// on the command line.
-
-// Volumes are the fourth type of elementary entities in Gmsh. In the
-// same way one defines line loops to build surfaces, one has to
-// define surface loops to build volumes. The following volumes are
-// very simple, without holes (and thus consist of only one surface
-// loop):
-
-Surface Loop(145) = @{121,11,131,135,139,144@};
-Volume(146) = @{145@};
-
-Surface Loop(146) = @{121,6,109,113,117,122@};
-Volume(147) = @{146@};
-
-// To save all volumic (tetrahedral) elements of volume 146 and 147
-// with the associate region number 1, a Physical Volume must be
-// defined:
-
-Physical Volume (1) = @{146,147@} ;
-
-// Congratulations! You've created your first fully unstructured
-// tetrahedral 3D mesh!
-}
-@end format
diff --git a/doc/texinfo/t3.geo b/doc/texinfo/t3.geo
deleted file mode 100644
index e96f932ff2a20d1dcc38f7e5aeb43b8982e8f140..0000000000000000000000000000000000000000
--- a/doc/texinfo/t3.geo
+++ /dev/null
@@ -1,83 +0,0 @@
-@format
-@code{
-/********************************************************************* 
- *
- *  Gmsh tutorial 3
- * 
- *  Extruded meshes, Options
- *
- *********************************************************************/
-
-// Again, the first tutorial example is included:
-
-Include "t1.geo" ;
-
-// As in 't2.geo', an extrusion along the z axis will be performed:
-
-h = 0.1 ;
-
-// But contrary to 't2.geo', not only the geometry will be extruded,
-// but also the 2D mesh. This is done with the same Extrude command,
-// but by specifying the number of layers (here, there will be four
-// layers, of respectively 8, 4, 2 and 1 elements in depth), with
-// volume numbers 9000 to 9003 and respective heights equal to h/4:
-
-Extrude Surface @{ 6, @{0,0,h@} @} @{ 
-  Layers @{ @{8,4,2,1@}, @{9000:9003@}, @{0.25,0.5,0.75,1@} @} ; 
-@} ;
-
-// The extrusion can also performed with a rotation instead of a
-// translation, and the resulting mesh can be recombined into prisms
-// (wedges) if the surface elements are triangles, or hexahedra if the
-// surface elements are quadrangles. All rotations are specified by an
-// axis direction (@{0,1,0@}), an axis point (@{-0.1,0,0.1@}) and a
-// rotation angle (-Pi/2):
-
-Extrude Surface @{ 122, @{0,1,0@} , @{-0.1,0,0.1@} , -Pi/2 @} @{ 
-  Recombine ; Layers @{ 7, 9004, 1 @} ; 
-@};
-
-// A translation (@{-2*h,0,0@}) and a rotation (@{1,0,0@} , @{0,0.15,0.25@},
-// Pi/2) can be combined:
-
-Extrude Surface @{news-1, @{-2*h,0,0@}, @{1,0,0@} , @{0,0.15,0.25@} , Pi/2@}@{ 
-  Layers @{10,9004,1@}; Recombine; 
-@};
-
-Physical Volume(101) = @{9000:9004@};
-
-// All interactive options can also be set directly in the input file.
-// For example, the following lines define a global characteristic
-// length factor, redefine some background colors, disable the display
-// of the axes, and select an initial viewpoint in XYZ mode (disabling
-// the interactive trackball-like rotation mode):
-
-Mesh.CharacteristicLengthFactor = 4;
-General.Color.Background = @{120,120,120@};
-General.Color.Foreground = @{255,255,255@};
-General.Color.Text = White;
-Geometry.Color.Points = Orange;
-General.Axes = 0;
-General.Trackball = 0;
-General.RotationX = 10;
-General.RotationY = 70;
-General.TranslationX = -0.2;
-
-// Note: all colors can be defined literally or numerically, i.e.
-// 'General.Color.Background = Red' is equivalent to
-// 'General.Color.Background = @{255,0,0@}'. As with user-defined
-// variables, the options can be used either as right hand or left
-// hand sides, so that
-
-Geometry.Color.Surfaces = Geometry.Color.Points;
-
-// will assign the color of the surfaces in the geometry to the same
-// color as the points.
-
-// A click on the '?'  button in the status bar of the graphic window
-// will dump all current options to the terminal. To save all
-// available options to a file, use the 'File->Save as->Gmsh options'
-// menu. To save the current options as the default options for all
-// future Gmsh sessions, use the 'Tools->Options->Save' button.
-}
-@end format
diff --git a/doc/texinfo/t4.geo b/doc/texinfo/t4.geo
deleted file mode 100644
index 8648ec8a4aea5e6c8e68926145fa3d760ad95fc8..0000000000000000000000000000000000000000
--- a/doc/texinfo/t4.geo
+++ /dev/null
@@ -1,172 +0,0 @@
-@format
-@code{
-/********************************************************************* 
- *
- *  Gmsh tutorial 4
- * 
- *  Built-in functions, Holes, Strings, Mesh color
- *
- *********************************************************************/
-
-cm = 1e-02 ;
-
-e1 = 4.5*cm ; e2 = 6*cm / 2 ; e3 =  5*cm / 2 ;
-
-h1 = 5*cm ; h2 = 10*cm ; h3 = 5*cm ; h4 = 2*cm ; h5 = 4.5*cm ;
-
-R1 = 1*cm ; R2 = 1.5*cm ; r = 1*cm ;
-
-ccos = ( -h5*R1 + e2 * Hypot(h5,Hypot(e2,R1)) ) / (h5^2 + e2^2) ;
-ssin = Sqrt(1-ccos^2) ;
-
-Lc1 = 0.01 ;
-Lc2 = 0.003 ;
-
-// A whole set of operators can be used, which can be combined in all
-// the expressions. These operators are defined in a similar way to
-// their C or C++ equivalents (with the exception of '^'):
-//
-//   '-' (in both unary and binary versions, i.e. as in '-1' and '1-2')
-//   '!' (the negation)
-//   '+'
-//   '*'
-//   '/'
-//   '%' (the rest of the integer division)
-//   '<'
-//   '>'
-//   '<='
-//   '>='
-//   '=='
-//   '!='
-//   '&&' (and)
-//   '||' (or)
-//   '||' (or)
-//   '^' (power)
-//   '?' ':' (the ternary operator)
-//
-// Grouping is done, as usual, with parentheses.
-//
-// In addition to these operators, all C mathematical functions can
-// also be used (note the first capital letter), i.e.
-// 
-//   Exp(x)
-//   Log(x)
-//   Log10(x)
-//   Sqrt(x)
-//   Sin(x)
-//   Asin(x)
-//   Cos(x)
-//   Acos(x)
-//   Tan(x)
-//   Atan(x)
-//   Atan2(x,y)
-//   Sinh(x)
-//   Cosh(x)
-//   Tanh(x)
-//   Fabs(x)
-//   Floor(x)
-//   Ceil(x)
-//   Fmod(x,y)
-// 
-// as well as a series of other functions:
-//
-//   Hypot(x,y)   computes Sqrt(x^2+y^2)
-//   Rand(x)      generates a random number in [0,x]
-//
-// The only predefined constant in Gmsh is Pi.
-
-Point(1) = @{ -e1-e2, 0.0  , 0.0 , Lc1@};
-Point(2) = @{ -e1-e2, h1   , 0.0 , Lc1@};
-Point(3) = @{ -e3-r , h1   , 0.0 , Lc2@};
-Point(4) = @{ -e3-r , h1+r , 0.0 , Lc2@};
-Point(5) = @{ -e3   , h1+r , 0.0 , Lc2@};
-Point(6) = @{ -e3   , h1+h2, 0.0 , Lc1@};
-Point(7) = @{  e3   , h1+h2, 0.0 , Lc1@};
-Point(8) = @{  e3   , h1+r , 0.0 , Lc2@};
-Point(9) = @{  e3+r , h1+r , 0.0 , Lc2@};
-Point(10)= @{  e3+r , h1   , 0.0 , Lc2@};
-Point(11)= @{  e1+e2, h1   , 0.0 , Lc1@};
-Point(12)= @{  e1+e2, 0.0  , 0.0 , Lc1@};
-Point(13)= @{  e2   , 0.0  , 0.0 , Lc1@};
-
-Point(14)= @{  R1 / ssin , h5+R1*ccos, 0.0 , Lc2@};
-Point(15)= @{  0.0       , h5        , 0.0 , Lc2@};
-Point(16)= @{ -R1 / ssin , h5+R1*ccos, 0.0 , Lc2@};
-Point(17)= @{ -e2        , 0.0       , 0.0 , Lc1@};
-
-Point(18)= @{ -R2  , h1+h3   , 0.0 , Lc2@};
-Point(19)= @{ -R2  , h1+h3+h4, 0.0 , Lc2@};
-Point(20)= @{  0.0 , h1+h3+h4, 0.0 , Lc2@};
-Point(21)= @{  R2  , h1+h3+h4, 0.0 , Lc2@};
-Point(22)= @{  R2  , h1+h3   , 0.0 , Lc2@};
-Point(23)= @{  0.0 , h1+h3   , 0.0 , Lc2@};
-
-Point(24)= @{  0 , h1+h3+h4+R2, 0.0 , Lc2@};
-Point(25)= @{  0 , h1+h3-R2,    0.0 , Lc2@};
-
-Line(1)  = @{1 ,17@};
-Line(2)  = @{17,16@};
-
-// All curves are not straight lines... Circles are defined by a list
-// of three point numbers, which represent the starting point, the
-// center and the end point, respectively. All circles have to be
-// defined in the trigonometric (counter-clockwise) sense.  Note that
-// the 3 points should not be aligned (otherwise the plane in which
-// the circle lies has to be defined, by 'Circle(num) =
-// @{start,center,end@} Plane @{nx,ny,nz@}').
-
-Circle(3) = @{14,15,16@};
-Line(4)  = @{14,13@};
-Line(5)  = @{13,12@};
-Line(6)  = @{12,11@};
-Line(7)  = @{11,10@};
-Circle(8) = @{ 8, 9,10@};
-Line(9)  = @{ 8, 7@};
-Line(10) = @{ 7, 6@};
-Line(11) = @{ 6, 5@};
-Circle(12) = @{ 3, 4, 5@};
-Line(13) = @{ 3, 2@};
-Line(14) = @{ 2, 1@};
-Line(15) = @{18,19@};
-Circle(16) = @{21,20,24@};
-Circle(17) = @{24,20,19@};
-Circle(18) = @{18,23,25@};
-Circle(19) = @{25,23,22@};
-Line(20) = @{21,22@};
-
-Line Loop(21) = @{17,-15,18,19,-20,16@};
-Plane Surface(22) = @{21@};
-
-// The surface is made of two line loops, i.e. it has one hole:
-
-Line Loop(23) = @{11,-12,13,14,1,2,-3,4,5,6,7,-8,9,10@};
-Plane Surface(24) = @{23,21@};
-
-Physical Surface(1) = @{22@};
-Physical Surface(2) = @{24@};
-
-// You can add some comments by simply embedding a post-processing
-// view with some strings...
-
-View "comments" @{
-  T2(10,15,0)@{"File created on Fri Oct 18 23:50:20 2002"@};
-  T2(10,-10,0)@{"Copyright (C) My Company"@};
-  T3(0,0.11,0,0)@{"Hole"@};
-@};
-
-// This will put the strings
-// - "File ..." 10 pixels from the left and 15 pixels from the top of
-//   the graphic window;
-// - "Copyright ..." 10 pixels from the left and 10 pixels from the
-//   bottom of the graphic window; and
-// - "Hole" in your model, at (x,y,z)=(0.0,0.11,0.0).
-
-// You can also change the color of the mesh entities for each
-// curve/surface:
-
-Color White@{ Surface@{ 22 @} ; @}
-Color Purple@{ Surface@{ 24 @} ; @}
-Color Red@{ Line@{ 1:14 @} ; @}
-Color Yellow@{ Line@{ 15:20 @} ; @}
-}
-@end format
diff --git a/doc/texinfo/t5.geo b/doc/texinfo/t5.geo
deleted file mode 100644
index 6446ba2bb0129eeaea2b802abff0c09b7b14489c..0000000000000000000000000000000000000000
--- a/doc/texinfo/t5.geo
+++ /dev/null
@@ -1,181 +0,0 @@
-@format
-@code{
-/********************************************************************* 
- *
- *  Gmsh tutorial 5
- * 
- *  Characteristic lengths, Arrays of variables, Functions, Loops
- *
- *********************************************************************/
-
-// This defines some characteristic lengths:
-
-lcar1 = .1;
-lcar2 = .0005;
-lcar3 = .055;
-
-// In order to change these lengths globally (without changing the
-// file), a global scaling factor for all characteristic lengths can
-// be specified on the command line with the option '-clscale' (or
-// with the option Mesh.CharacteristicLengthFactor). For example,
-// with:
-//
-// > gmsh t5 -clscale 1
-//
-// this example produces a mesh of approximately 2000 nodes and
-// 10,000 tetrahedra (in 3 seconds on an alpha workstation running at
-// 666MHz). With 
-//
-// > gmsh t5 -clscale 0.2
-//
-// (i.e. with all characteristic lengths divided by 5), the mesh
-// counts approximately 170,000 nodes and one million tetrahedra
-// (and the computation takes 16 minutes on the same machine :-( So
-// there is still a lot of work to do to achieve decent performance
-// with Gmsh...)
-
-Point(1) = @{0.5,0.5,0.5,lcar2@}; Point(2) = @{0.5,0.5,0,lcar1@};
-Point(3) = @{0,0.5,0.5,lcar1@};   Point(4) = @{0,0,0.5,lcar1@}; 
-Point(5) = @{0.5,0,0.5,lcar1@};   Point(6) = @{0.5,0,0,lcar1@};
-Point(7) = @{0,0.5,0,lcar1@};     Point(8) = @{0,1,0,lcar1@};
-Point(9) = @{1,1,0,lcar1@};       Point(10) = @{0,0,1,lcar1@};
-Point(11) = @{0,1,1,lcar1@};      Point(12) = @{1,1,1,lcar1@};
-Point(13) = @{1,0,1,lcar1@};      Point(14) = @{1,0,0,lcar1@};
-
-Line(1) = @{8,9@};    Line(2) = @{9,12@};  Line(3) = @{12,11@};
-Line(4) = @{11,8@};   Line(5) = @{9,14@};  Line(6) = @{14,13@};
-Line(7) = @{13,12@};  Line(8) = @{11,10@}; Line(9) = @{10,13@};
-Line(10) = @{10,4@};  Line(11) = @{4,5@};  Line(12) = @{5,6@};
-Line(13) = @{6,2@};   Line(14) = @{2,1@};  Line(15) = @{1,3@};
-Line(16) = @{3,7@};   Line(17) = @{7,2@};  Line(18) = @{3,4@};
-Line(19) = @{5,1@};   Line(20) = @{7,8@};  Line(21) = @{6,14@};
-
-Line Loop(22) = @{11,19,15,18@};       Plane Surface(23) = @{22@};
-Line Loop(24) = @{16,17,14,15@};       Plane Surface(25) = @{24@};
-Line Loop(26) = @{-17,20,1,5,-21,13@}; Plane Surface(27) = @{26@};
-Line Loop(28) = @{4,1,2,3@};           Plane Surface(29) = @{28@};
-Line Loop(30) = @{7,-2,5,6@};          Plane Surface(31) = @{30@};
-Line Loop(32) = @{6,-9,10,11,12,21@};  Plane Surface(33) = @{32@};
-Line Loop(34) = @{7,3,8,9@};           Plane Surface(35) = @{34@};
-Line Loop(36) = @{10,-18,16,20,-4,8@}; Plane Surface(37) = @{36@};
-Line Loop(38) = @{-14,-13,-12,19@};    Plane Surface(39) = @{38@};
-
-// Instead of using included files, one can also define functions. In
-// the following function, the reserved variable 'newp' is used, which
-// automatically selects a new point number. This number is chosen as
-// the highest current point number, plus one. Analogously to 'newp',
-// there exists a variable 'newreg' which selects the highest number
-// of all entities other than points, plus one.
-
-// Note: there are no local variables. This will be changed in a
-// future version of Gmsh.
-
-Function CheeseHole 
-
-  p1 = newp; Point(p1) = @{x,  y,  z,  lcar3@} ;
-  p2 = newp; Point(p2) = @{x+r,y,  z,  lcar3@} ;
-  p3 = newp; Point(p3) = @{x,  y+r,z,  lcar3@} ;
-  p4 = newp; Point(p4) = @{x,  y,  z+r,lcar3@} ;
-  p5 = newp; Point(p5) = @{x-r,y,  z,  lcar3@} ;
-  p6 = newp; Point(p6) = @{x,  y-r,z,  lcar3@} ;
-  p7 = newp; Point(p7) = @{x,  y,  z-r,lcar3@} ;
-
-  c1 = newreg; Circle(c1) = @{p2,p1,p7@};
-  c2 = newreg; Circle(c2) = @{p7,p1,p5@};
-  c3 = newreg; Circle(c3) = @{p5,p1,p4@};
-  c4 = newreg; Circle(c4) = @{p4,p1,p2@};
-  c5 = newreg; Circle(c5) = @{p2,p1,p3@};
-  c6 = newreg; Circle(c6) = @{p3,p1,p5@};
-  c7 = newreg; Circle(c7) = @{p5,p1,p6@};
-  c8 = newreg; Circle(c8) = @{p6,p1,p2@};
-  c9 = newreg; Circle(c9) = @{p7,p1,p3@};
-  c10 = newreg; Circle(c10) = @{p3,p1,p4@};
-  c11 = newreg; Circle(c11) = @{p4,p1,p6@};
-  c12 = newreg; Circle(c12) = @{p6,p1,p7@};
-
-// All surfaces are not plane... Here is the way to define ruled
-// surfaces (which have 3 or 4 borders):
-
-  l1 = newreg; Line Loop(l1) = @{c5,c10,c4@};   Ruled Surface(newreg) = @{l1@};
-  l2 = newreg; Line Loop(l2) = @{c9,-c5,c1@};   Ruled Surface(newreg) = @{l2@};
-  l3 = newreg; Line Loop(l3) = @{-c12,c8,c1@};  Ruled Surface(newreg) = @{l3@};
-  l4 = newreg; Line Loop(l4) = @{c8,-c4,c11@};  Ruled Surface(newreg) = @{l4@};
-  l5 = newreg; Line Loop(l5) = @{-c10,c6,c3@};  Ruled Surface(newreg) = @{l5@};
-  l6 = newreg; Line Loop(l6) = @{-c11,-c3,c7@}; Ruled Surface(newreg) = @{l6@};
-  l7 = newreg; Line Loop(l7) = @{c2,c7,c12@};   Ruled Surface(newreg) = @{l7@};
-  l8 = newreg; Line Loop(l8) = @{-c6,-c9,c2@};  Ruled Surface(newreg) = @{l8@};
-
-// Warning: surface meshes are generated by projecting a 2D mesh in
-// the mean plane of the surface. This gives nice results only if the
-// surface curvature is small enough. Otherwise you will have to cut
-// the surface in pieces.
-
-// Arrays of variables can be manipulated in the same way as classical
-// variables. Warning: accessing an uninitialized element in an array
-// will produce an unpredictable result. Note that whole arrays can
-// also be instantly initialized (e.g. l[]=@{1,2,7@} is valid).
-
-  theloops[t] = newreg ; 
-
-  Surface Loop(theloops[t]) = @{l8+1, l5+1, l1+1, l2+1, -(l3+1), -(l7+1),
-			       l6+1, l4+1@};
-
-  thehole = newreg ; 
-  Volume(thehole) = theloops[t] ;
-
-Return
-
-
-x = 0 ; y = 0.75 ; z = 0 ; r = 0.09 ;
-
-// A For loop is used to generate five holes in the cube:
-
-For t In @{1:5@}
-
-  x += 0.166 ; 
-  z += 0.166 ; 
-
-// This command calls the function CheeseHole. Note that, instead of
-// defining a function, we could have defined a file containing the
-// same code, and used the Include command to include this file.
-
-  Call CheeseHole ;
-
-// A physical volume is defined for each cheese hole
-
-  Physical Volume (t) = thehole ;
- 
-// The Printf function permits to print the value of variables on the
-// terminal, in a way similar to the 'printf' C function:
-
-  Printf("Hole %g (center = @{%g,%g,%g@}, radius = %g) has number %g!",
-	 t, x, y, z, r, thehole) ;
-
-// Note: All Gmsh variables are treated internally as double precision
-// numbers. The format string should thus only contain valid double
-// precision number format specifiers (see the C or C++ language
-// reference for more details).
-
-EndFor
-
-// This is the surface loop for the exterior surface of the cube:
-
-theloops[0] = newreg ;
-
-Surface Loop(theloops[0]) = @{35,31,29,37,33,23,39,25,27@} ;
-
-// The volume of the cube, without the 5 cheese holes, is defined by 6
-// surface loops (the exterior surface and the five interior loops).
-// To reference an array of variables, its identifier is followed by
-// '[]':
-
-Volume(186) = @{theloops[]@} ;
-
-// This physical volume assigns the region number 10 to the tetrahedra
-// paving the cube (but not the holes, whose elements were tagged from
-// 1 to 5 in the 'For' loop)
-
-Physical Volume (10) = 186 ;
-
-}
-@end format
diff --git a/doc/texinfo/t6.geo b/doc/texinfo/t6.geo
deleted file mode 100644
index f5e540cbd84e76ee1c4b55d7ee81a21765087ed3..0000000000000000000000000000000000000000
--- a/doc/texinfo/t6.geo
+++ /dev/null
@@ -1,258 +0,0 @@
-@format
-@code{
-/********************************************************************* 
- *
- *  Gmsh tutorial 6
- * 
- *  Transfinite meshes
- *
- *********************************************************************/
-
-r_int  = 0.05 ;
-r_ext  = 0.051 ;
-r_far  = 0.125 ;
-r_inf  = 0.4 ;
-phi1   = 30. * (Pi/180.) ;
-angl   = 45. * (Pi/180.) ;
-
-nbpt_phi   = 5 ; nbpt_int   = 20 ;
-nbpt_arc1  = 10 ; nbpt_arc2  = 10 ;
-nbpt_shell = 10 ; nbpt_far   = 25 ; nbpt_inf = 15 ;
-
-lc0 = 0.1 ; lc1 = 0.1 ; lc2 = 0.3 ;
-
-Point(1) = @{0,     0, 0, lc0@} ;
-Point(2) = @{r_int, 0, 0, lc0@} ;
-Point(3) = @{r_ext, 0, 0, lc1@} ;
-Point(4) = @{r_far, 0, 0, lc2@} ;
-Point(5) = @{r_inf, 0, 0, lc2@} ;
-Point(6) = @{0, 0,  r_int, lc0@} ;
-Point(7) = @{0, 0,  r_ext, lc1@} ;
-Point(8) = @{0, 0,  r_far, lc2@} ;
-Point(9) = @{0, 0,  r_inf, lc2@} ;
-
-Point(10) = @{r_int*Cos(phi1), r_int*Sin(phi1), 0, lc0@} ;
-Point(11) = @{r_ext*Cos(phi1), r_ext*Sin(phi1), 0, lc1@} ;
-Point(12) = @{r_far*Cos(phi1), r_far*Sin(phi1), 0, lc2@} ;
-Point(13) = @{r_inf*Cos(phi1), r_inf*Sin(phi1), 0, lc2@} ;
-
-Point(14) = @{r_int/2, 0, 0, lc2@} ;
-Point(15) = @{r_int/2*Cos(phi1), r_int/2*Sin(phi1), 0, lc2@} ;
-Point(16) = @{r_int/2, 0, r_int/2, lc2@} ;
-Point(17) = @{r_int/2*Cos(phi1), r_int/2*Sin(phi1), r_int/2, lc2@} ;
-Point(18) = @{0, 0, r_int/2, lc2@} ;
-Point(19) = @{r_int*Cos(angl), 0, r_int*Sin(angl), lc2@} ;
-Point(20) = @{r_int*Cos(angl)*Cos(phi1), r_int*Cos(angl)*Sin(phi1),
-	     r_int*Sin(angl), lc2@} ;
-Point(21) = @{r_ext*Cos(angl), 0, r_ext*Sin(angl), lc2@} ;
-Point(22) = @{r_ext*Cos(angl)*Cos(phi1), r_ext*Cos(angl)*Sin(phi1),
-	     r_ext*Sin(angl), lc2@} ;
-Point(23) = @{r_far*Cos(angl), 0, r_far*Sin(angl), lc2@} ;
-Point(24) = @{r_far*Cos(angl)*Cos(phi1), r_far*Cos(angl)*Sin(phi1),
-	     r_far*Sin(angl), lc2@} ;
-Point(25) = @{r_inf, 0, r_inf, lc2@} ;
-Point(26) = @{r_inf*Cos(phi1), r_inf*Sin(phi1),  r_inf, lc2@} ;
-
-Circle(1) = @{2,1,19@};  Circle(2) = @{19,1,6@};  Circle(3) = @{3,1,21@};
-Circle(4) = @{21,1,7@};  Circle(5) = @{4,1,23@};  Circle(6) = @{23,1,8@};   
-Line(7)   = @{5,25@};    Line(8)   = @{25,9@};
-Circle(9) = @{10,1,20@}; Circle(10)= @{20,1,6@};  Circle(11) = @{11,1,22@};
-Circle(12)= @{22,1,7@};  Circle(13)= @{12,1,24@}; Circle(14) = @{24,1,8@};
-Line(15)  = @{13,26@};   Line(16)  = @{26,9@};
-Circle(17)= @{19,1,20@}; Circle(18)= @{21,1,22@}; Circle(19) = @{23,1,24@};
-Circle(20)= @{25,1,26@}; Circle(21)= @{2,1,10@};  Circle(22) = @{3,1,11@};  
-Circle(23)= @{4,1,12@};  Circle(24)= @{5,1,13@};
-
-Line(25) = @{1,14@};  Line(26) = @{14,2@};  Line(27) = @{2,3@};
-Line(28) = @{3,4@};   Line(29) = @{4,5@};   Line(30) = @{1,15@};
-Line(31) = @{15,10@}; Line(32) = @{10,11@}; Line(33) = @{11,12@};
-Line(34) = @{12,13@}; Line(35) = @{14,15@}; Line(36) = @{14,16@};
-Line(37) = @{15,17@}; Line(38) = @{16,17@}; Line(39) = @{18,16@};
-Line(40) = @{18,17@}; Line(41) = @{1,18@};  Line(42) = @{18,6@};
-Line(43) = @{6,7@};   Line(44) = @{16,19@}; Line(45) = @{19,21@};
-Line(46) = @{21,23@}; Line(47) = @{23,25@}; Line(48) = @{17,20@};
-Line(49) = @{20,22@}; Line(50) = @{22,24@}; Line(51) = @{24,26@};
-Line(52) = @{7,8@};   Line(53) = @{8,9@};
-
-Line Loop(54) = @{39,-36,-25,41@};  Ruled Surface(55) = @{54@};
-Line Loop(56) = @{44,-1,-26,36@};   Ruled Surface(57) = @{56@};
-Line Loop(58) = @{3,-45,-1,27@};    Ruled Surface(59) = @{58@};
-Line Loop(60) = @{5,-46,-3,28@};    Ruled Surface(61) = @{60@};
-Line Loop(62) = @{7,-47,-5,29@};    Ruled Surface(63) = @{62@};
-Line Loop(64) = @{-2,-44,-39,42@};  Ruled Surface(65) = @{64@};
-Line Loop(66) = @{-4,-45,2,43@};    Ruled Surface(67) = @{66@};
-Line Loop(68) = @{-6,-46,4,52@};    Ruled Surface(69) = @{68@};
-Line Loop(70) = @{-8,-47,6,53@};    Ruled Surface(71) = @{70@};
-Line Loop(72) = @{-40,-41,30,37@};  Ruled Surface(73) = @{72@};
-Line Loop(74) = @{48,-9,-31,37@};   Ruled Surface(75) = @{74@};
-Line Loop(76) = @{49,-11,-32,9@};   Ruled Surface(77) = @{76@};
-Line Loop(78) = @{-50,-11,33,13@};  Ruled Surface(79) = @{78@};
-Line Loop(80) = @{-51,-13,34,15@};  Ruled Surface(81) = @{80@};
-Line Loop(82) = @{10,-42,40,48@};   Ruled Surface(83) = @{82@};
-Line Loop(84) = @{12,-43,-10,49@};  Ruled Surface(85) = @{84@};
-Line Loop(86) = @{14,-52,-12,50@};  Ruled Surface(87) = @{86@};
-Line Loop(88) = @{16,-53,-14,51@};  Ruled Surface(89) = @{88@};
-Line Loop(90) = @{-30,25,35@};      Ruled Surface(91) = @{90@};
-Line Loop(92) = @{-40,39,38@};      Ruled Surface(93) = @{92@};
-Line Loop(94) = @{37,-38,-36,35@};  Ruled Surface(95) = @{94@};
-Line Loop(96) = @{-48,-38,44,17@};  Ruled Surface(97) = @{96@};
-Line Loop(98) = @{18,-49,-17,45@};  Ruled Surface(99) = @{98@};
-Line Loop(100) = @{19,-50,-18,46@}; Ruled Surface(101) = @{100@};
-Line Loop(102) = @{20,-51,-19,47@}; Ruled Surface(103) = @{102@};
-Line Loop(104) = @{-2,17,10@};      Ruled Surface(105) = @{104@};
-Line Loop(106) = @{-9,-21,1,17@};   Ruled Surface(107) = @{106@};
-Line Loop(108) = @{-4,18,12@};      Ruled Surface(109) = @{108@};
-Line Loop(110) = @{-11,-22,3,18@};  Ruled Surface(111) = @{110@};
-Line Loop(112) = @{-13,-23,5,19@};  Ruled Surface(113) = @{112@};
-Line Loop(114) = @{-6,19,14@};      Ruled Surface(115) = @{114@};
-Line Loop(116) = @{-15,-24,7,20@};  Ruled Surface(117) = @{116@};
-Line Loop(118) = @{-8,20,16@};      Ruled Surface(119) = @{118@};
-Line Loop(120) = @{-31,-35,26,21@}; Ruled Surface(121) = @{120@};
-Line Loop(122) = @{32,-22,-27,21@}; Ruled Surface(123) = @{122@};
-Line Loop(124) = @{33,-23,-28,22@}; Ruled Surface(125) = @{124@};
-Line Loop(126) = @{34,-24,-29,23@}; Ruled Surface(127) = @{126@};
-
-Surface Loop(128) = @{93,-73,-55,95,-91@};
-Volume(129) = @{128@}; // int
-Surface Loop(130) = @{107,-75,-97,95,57,121@};
-Volume(131) = @{130@}; // int b
-Surface Loop(132) = @{105,-65,-97,-83,-93@};
-Volume(133) = @{132@}; // int h
-Surface Loop(134) = @{99,-111,77,123,59,107@};
-Volume(135) = @{134@}; // shell b
-Surface Loop(136) = @{99,-109,67,105,85@};
-Volume(137) = @{136@}; // shell h
-Surface Loop(138) = @{113,79,-101,-111,-125,-61@};
-Volume(139) = @{138@}; // ext b
-Surface Loop(140) = @{115,-69,-101,-87,-109@};
-Volume(141) = @{140@}; // ext h
-Surface Loop(142) = @{103,-117,-81,113,127,63@};
-Volume(143) = @{142@}; // inf b
-Surface Loop(144) = @{89,-119,71,103,115@};
-Volume(145) = @{144@}; // inf h
-
-// Transfinite line commands explicitly specify the number of points
-// and their distribution. 'Progression 2' means that each line
-// element in the series will be twice as long as the preceding one.
-
-Transfinite Line@{35,21,22,23,24,38,17,18,19,20@} = nbpt_phi ;
-Transfinite Line@{31,26,48,44,42@} = nbpt_int Using Progression 0.88;
-Transfinite Line@{41,37,36,9,11,1,3,13,5,15,7@} = nbpt_arc1 ;
-Transfinite Line@{30,25,40,39,10,2,12,4,14,6,16,8@} = nbpt_arc2 ;
-Transfinite Line@{32,27,49,45,43@} = nbpt_shell ;
-Transfinite Line@{33,28,46,50,52@} = nbpt_far Using Progression 1.2 ;
-Transfinite Line@{34,29,51,47,53@} = nbpt_inf Using Progression 1.05;
-
-// 2D transfinite entities are defined in respect to points. The
-// ordering of the points defines the ordering of the mesh elements.
-// A transfinite surface can have either 3 or 4 sides.
-
-Transfinite Surface@{55@} = @{1,14,16,18@};
-Transfinite Surface@{57@} = @{14,2,19,16@};
-Transfinite Surface@{59@} = @{2,3,21,19@};
-Transfinite Surface@{61@} = @{3,4,23,21@};
-Transfinite Surface@{63@} = @{4,5,25,23@};
-Transfinite Surface@{73@} = @{1,15,17,18@};
-Transfinite Surface@{75@} = @{15,10,20,17@};
-Transfinite Surface@{77@} = @{10,11,22,20@};
-Transfinite Surface@{79@} = @{11,12,24,22@};
-Transfinite Surface@{81@} = @{12,13,26,24@};
-Transfinite Surface@{65@} = @{18,16,19,6@};
-Transfinite Surface@{67@} = @{6,19,21,7@};
-Transfinite Surface@{69@} = @{7,21,23,8@};
-Transfinite Surface@{71@} = @{8,23,25,9@};
-Transfinite Surface@{83@} = @{17,18,6,20@};
-Transfinite Surface@{85@} = @{20,6,7,22@};
-Transfinite Surface@{87@} = @{22,7,8,24@};
-Transfinite Surface@{89@} = @{24,8,9,26@};
-Transfinite Surface@{91@} = @{1,14,15@};
-Transfinite Surface@{95@} = @{15,14,16,17@};
-Transfinite Surface@{93@} = @{18,16,17@};
-Transfinite Surface@{121@} = @{15,14,2,10@};
-Transfinite Surface@{97@} = @{17,16,19,20@};
-Transfinite Surface@{123@} = @{10,2,3,11@};
-Transfinite Surface@{99@} = @{20,19,21,22@};
-Transfinite Surface@{107@} = @{10,2,19,20@};
-Transfinite Surface@{105@} = @{6,20,19@};
-Transfinite Surface@{109@} = @{7,22,21@};
-Transfinite Surface@{111@} = @{11,3,21,22@};
-Transfinite Surface@{101@} = @{22,21,23,24@};
-Transfinite Surface@{125@} = @{11,3,4,12@};
-Transfinite Surface@{115@} = @{8,24,23@};
-Transfinite Surface@{113@} = @{24,12,4,23@};
-Transfinite Surface@{127@} = @{12,13,5,4@};
-Transfinite Surface@{103@} = @{24,23,25,26@};
-Transfinite Surface@{119@} = @{9,26,25@};
-Transfinite Surface@{117@} = @{13,5,25,26@};
-
-// As with Extruded meshes, the Recombine command tells Gmsh to
-// recombine the simplices into quadrangles, prisms or hexahedra when
-// possible. A colon in a list acts as in the 'For' loop: all surfaces
-// having numbers between 55 and 127 are considered.
-
-Recombine Surface @{55:127@};
-
-// 3D transfinite entities are defined in respect to points. The
-// ordering of the points defines the ordering of the mesh elements.
-// A transfinite volume can have either 6 or 8 faces.
-
-Transfinite Volume@{129@} = @{1,14,15,18,16,17@};
-Transfinite Volume@{131@} = @{17,16,14,15,20,19,2,10@};
-Transfinite Volume@{133@} = @{18,17,16,6,20,19@};
-Transfinite Volume@{135@} = @{10,2,19,20,11,3,21,22@};
-Transfinite Volume@{137@} = @{6,20,19,7,22,21@};
-Transfinite Volume@{139@} = @{11,3,4,12,22,21,23,24@};
-Transfinite Volume@{141@} = @{7,22,21,8,24,23@};
-Transfinite Volume@{143@} = @{12,4,5,13,24,23,25,26@};
-Transfinite Volume@{145@} = @{8,24,23,9,26,25@};
-
-VolInt           = 1000 ;
-SurfIntPhi0      = 1001 ;
-SurfIntPhi1      = 1002 ;
-SurfIntZ0        = 1003 ;
-
-VolShell         = 2000 ;
-SurfShellInt     = 2001 ;
-SurfShellExt     = 2002 ;
-SurfShellPhi0    = 2003 ;
-SurfShellPhi1    = 2004 ;
-SurfShellZ0      = 2005 ;
-LineShellIntPhi0 = 2006 ;
-LineShellIntPhi1 = 2007 ;
-LineShellIntZ0   = 2008 ;
-PointShellInt    = 2009 ;
-
-VolExt           = 3000 ;
-VolInf           = 3001 ;
-SurfInf          = 3002 ;
-SurfExtInfPhi0   = 3003 ;
-SurfExtInfPhi1   = 3004 ;
-SurfExtInfZ0     = 3005 ;
-SurfInfRight     = 3006 ;
-SurfInfTop       = 3007 ;
-
-Physical Volume  (VolInt)           = @{129,131,133@} ;
-Physical Surface (SurfIntPhi0)      = @{55,57,65@} ;
-Physical Surface (SurfIntPhi1)      = @{73,75,83@} ;
-Physical Surface (SurfIntZ0)        = @{91,121@} ;
-
-Physical Volume  (VolShell)         = @{135,137@} ;
-Physical Surface (SurfShellInt)     = @{105,107@} ;
-Physical Surface (SurfShellExt)     = @{109,111@} ;
-Physical Surface (SurfShellPhi0)    = @{59,67@} ;
-Physical Surface (SurfShellPhi1)    = @{77,85@} ;
-Physical Surface (SurfShellZ0)      = @{123@} ;
-Physical Line    (LineShellIntPhi0) = @{1,2@} ;
-Physical Line    (LineShellIntPhi1) = @{9,10@} ;
-Physical Line    (LineShellIntZ0)   = 21 ;
-Physical Point   (PointShellInt)    = 6 ;
-
-Physical Volume  (VolExt)           = @{139,141@} ;
-Physical Volume  (VolInf)           = @{143,145@} ;
-Physical Surface (SurfExtInfPhi0)   = @{61,63,69,71@} ;
-Physical Surface (SurfExtInfPhi1)   = @{79,87,81,89@} ;
-Physical Surface (SurfExtInfZ0)     = @{125,127@} ;
-Physical Surface (SurfInfRight)     = @{117@} ;
-Physical Surface (SurfInfTop)       = @{119@} ;
-}
-@end format
diff --git a/doc/texinfo/t7.geo b/doc/texinfo/t7.geo
deleted file mode 100644
index 132e95341d1cdb5c5753629e05200b7a51feec3e..0000000000000000000000000000000000000000
--- a/doc/texinfo/t7.geo
+++ /dev/null
@@ -1,51 +0,0 @@
-@format
-@code{
-/********************************************************************* 
- *
- *  Gmsh tutorial 7
- * 
- *  Anisotropic meshes, Attractors
- *
- *********************************************************************/
-
-// The anisotropic 2D mesh generator can be selected with:
-
-Mesh.Algorithm = 2 ;
-
-// One can force a 4 step Laplacian smoothing of the mesh with:
-
-Mesh.Smoothing = 4 ;
-
-lc = .1;
-
-Point(1) = @{0.0,0.0,0,lc@};
-Point(2) = @{1.2,-0.2,0,lc@};
-Point(3) = @{1,1,0,lc@};
-Point(4) = @{0,1,0,lc@};
-
-Line(1) = @{3,2@};
-Line(2) = @{2,1@};
-Line(3) = @{1,4@};
-Line(4) = @{4,3@};
-
-Line Loop(5) = @{1,2,3,4@};
-Plane Surface(6) = @{5@};
-
-Point(5) = @{0.1,0.2,0,lc@};
-Point(11) = @{0.5,0.5,-1,lc@};
-Point(12) = @{0.5,0.5,0,lc@};
-Point(22) = @{0.6,0.6,1,lc@};
-
-Line(5) = @{11,22@};
-
-Spline(7) = @{4,5,12,2@};
-
-// Anisotropic attractors can be defined on points and lines:
-
-Attractor Line@{5@} = @{.1, 0.01, 17@};
-
-Attractor Line@{1,2@} = @{0.1, 0.005, 3@};
-Attractor Line@{7@} = @{0.1, 0.05, 3@};
-
-}
-@end format
diff --git a/doc/texinfo/t8.geo b/doc/texinfo/t8.geo
deleted file mode 100644
index 78b1fe278816b9d9b8b591e08c8a9237a24f8759..0000000000000000000000000000000000000000
--- a/doc/texinfo/t8.geo
+++ /dev/null
@@ -1,135 +0,0 @@
-@format
-@code{
-/********************************************************************* 
- *
- *  Gmsh tutorial 8
- * 
- *  Post-Processing, Scripting, Animations, Options
- *
- *********************************************************************/
-
-// The first example is included, as well as some post-processing maps:
-
-Include "t1.geo" ;
-Include "view1.pos" ;
-Include "view1.pos" ;
-Include "view4.pos" ;
-
-// Some general options are set (all the options specified
-// interactively can be directly specified in the ascii input
-// files. The current options can be saved into a file by selecting
-// 'File->Save as->Gmsh options').
-
-General.Trackball = 0 ;
-General.RotationX = 0 ;
-General.RotationY = 0 ;
-General.RotationZ = 0 ;
-General.Color.Background = White ;
-General.Color.Foreground = Black ;
-General.Color.Text = Black ;
-General.Orthographic = 0 ;
-General.Axes = 0 ;
-General.SmallAxes = 0 ;
-
-// Some options are also specified for each post-processing view:
-
-v0 = PostProcessing.NbViews-4;
-v1 = v0+1;
-v2 = v0+2;
-v3 = v0+3;
-
-View[v0].IntervalsType = 2 ;
-View[v0].OffsetZ = 0.05 ;
-View[v0].RaiseZ = 0 ;
-View[v0].Light = 1 ;
-View[v0].ShowScale = 0;
-View[v0].SmoothNormals = 1;
-
-View[v1].IntervalsType = 1 ;
-View[v1].ColorTable = @{ Green, Blue @} ;
-View[v1].NbIso = 10 ;
-View[v1].ShowScale = 0;
-
-View[v2].Name = "Test..." ;
-View[v2].IntervalsType = 2 ;
-View[v2].Type = 2;
-View[v2].IntervalsType = 2 ;
-View[v2].AutoPosition = 0;
-View[v2].PositionX = 85;
-View[v2].PositionY = 50;
-View[v2].Width = 200;
-View[v2].Height = 130;
-
-View[v3].Type = 3;
-View[v3].RangeType = 2;
-View[v3].IntervalsType = 4 ;
-View[v3].ShowScale = 0;
-View[v3].Grid = 0;
-View[v3].CustomMin = View[v2].CustomMin;
-View[v3].CustomMax = View[v2].CustomMax;
-View[v3].AutoPosition = 0;
-View[v3].PositionX = View[v2].PositionX;
-View[v3].PositionY = View[v2].PositionY;
-View[v3].Width = View[v2].Width;
-View[v3].Height = View[v2].Height;
-
-// We loop from 1 to 255 with a step of 1 (to use a step different
-// from 1, just add a third argument in the list. For example, 'For
-// num In @{0.5:1.5:0.1@}' would increment num from 0.5 to 1.5 with a
-// step of 0.1).
-
-t = 0 ;
-
-For num In @{1:255@}
-
-  View[v0].TimeStep = t ;
-  View[v1].TimeStep = t ;
-  View[v2].TimeStep = t ;
-  View[v3].TimeStep = t ;
-
-  t = (View[v0].TimeStep < View[v0].NbTimeStep-1) ? t+1 : 0 ;
-  
-  View[v0].RaiseZ += 0.01*t ;
-
-  If (num == 3)
-    // We want to create 320x240 frames when num==3:
-    General.GraphicsWidth = 320 ; 
-    General.GraphicsHeight = 240 ;
-  EndIf
-
-  // It is possible to nest loops:
-  For num2 In @{1:50@}
-
-    General.RotationX += 10 ;
-    General.RotationY = General.RotationX / 3 ;
-    General.RotationZ += 0.1 ;
- 
-    Sleep 0.01; // sleep for 0.01 second
-    Draw; // draw the scene
-
-    If ((num == 3) && (num2 < 10))
-      // The Sprintf function permits to create complex strings using
-      // variables (since all Gmsh variables are treated internally as
-      // double precision numbers, the format should only contain valid
-      // double precision number format specifiers):
-      Print Sprintf("t8-0%g.gif", num2);
-      Print Sprintf("t8-0%g.jpg", num2);
-    EndIf
-
-    If ((num == 3) && (num2 >= 10))
-       Print Sprintf("t8-%g.gif", num2);
-       Print Sprintf("t8-%g.jpg", num2);
-    EndIf
-
-  EndFor
-
-  If(num == 3)
-    // We could make a system call to generate the mpeg (uncomment the
-    // following of mpeg_encode is installed on your computer)
-
-    // System "mpeg_encode t8.par" ;
-  EndIf
-
-EndFor
-}
-@end format
diff --git a/doc/texinfo/t9.geo b/doc/texinfo/t9.geo
deleted file mode 100644
index 15bdf350b0fcf6ad3dd5f9a9c37d0896383c18e8..0000000000000000000000000000000000000000
--- a/doc/texinfo/t9.geo
+++ /dev/null
@@ -1,49 +0,0 @@
-@format
-@code{
-/********************************************************************* 
- *
- *  Gmsh tutorial 9
- * 
- *  Post-Processing, Plugins
- *
- *********************************************************************/
-
-// Plugins can be added to Gmsh in order to extend its
-// capabilities. For example, post-processing plugins can modify a
-// view, or create a new view based on previously loaded
-// views. Several default plugins are statically linked into Gmsh,
-// e.g. CutMap, CutPlane, CutSphere, Skin, Transform or Smooth.
-
-// Let's load a three-dimensional scalar view
-
-Include "view3.pos" ;
-
-// Plugins can be controlled in the same way as other options in
-// Gmsh. For example, the CutMap plugin (which extracts an isovalue
-// surface from a 3D scalar view) can either be called from the
-// graphical interface (right click on the view button, then
-// Plugins->CutMap), or from the command file:
-
-Plugin(CutMap).A = 0.67 ; // iso-value level
-Plugin(CutMap).iView = 0 ; // source view is View[0]
-Plugin(CutMap).Run ; 
-
-// The following runs the CutPlane plugin:
-
-Plugin(CutPlane).A = 0 ; 
-Plugin(CutPlane).B = 0.2 ; 
-Plugin(CutPlane).C = 1 ; 
-Plugin(CutPlane).D = 0 ; 
-Plugin(CutPlane).Run ; 
-
-View[0].Light = 1;
-View[0].IntervalsType = 2;
-View[0].NbIso = 6;
-View[0].SmoothNormals = 1;
-
-View[1].IntervalsType = 2;
-
-View[2].IntervalsType = 2;
-Draw;
-}
-@end format
diff --git a/doc/texinfo/texinfo.tex b/doc/texinfo/texinfo.tex
index afa09a9f02886f3bfa1153227a46bb7e2b8c57cd..fb8e64d591a8f9975a58634ded2df7a8118540aa 100644
--- a/doc/texinfo/texinfo.tex
+++ b/doc/texinfo/texinfo.tex
@@ -1,13 +1,14 @@
-%%%modifie par christophe -> 'geuz'
+% modified for gmsh -- see 'gmsh' tags
+%
 % texinfo.tex -- TeX macros to handle Texinfo files.
 %
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{1999-09-25.10}
+\def\texinfoversion{2003-03-22.08}
 %
-% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
-% Free Software Foundation, Inc.
+% Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
+% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 %
 % This texinfo.tex file is free software; you can redistribute it and/or
 % modify it under the terms of the GNU General Public License as
@@ -30,16 +31,17 @@
 %
 % Please try the latest version of texinfo.tex before submitting bug
 % reports; you can get the latest version from:
-%   ftp://ftp.gnu.org/gnu/texinfo.tex
-%   (and all GNU mirrors, see http://www.gnu.org/order/ftp.html)
-%   ftp://texinfo.org/tex/texinfo.tex
-%   ftp://us.ctan.org/macros/texinfo/texinfo.tex
-%   (and all CTAN mirrors, finger ctan@us.ctan.org for a list).
-%   /home/gd/gnu/doc/texinfo.tex on the GNU machines.
+%   ftp://ftp.gnu.org/gnu/texinfo/texinfo.tex
+%     (and all GNU mirrors, see http://www.gnu.org/order/ftp.html)
+%   ftp://tug.org/tex/texinfo.tex
+%     (and all CTAN mirrors, see http://www.ctan.org),
+%   and /home/gd/gnu/doc/texinfo.tex on the GNU machines.
+% 
+% The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
+% 
 % The texinfo.tex in any given Texinfo distribution could well be out
 % of date, so if that's what you're using, please check.
-% Texinfo has a small home page at http://texinfo.org/.
-%
+% 
 % Send bug reports to bug-texinfo@gnu.org.  Please include including a
 % complete document in each bug report with which we can reproduce the
 % problem.  Patches are, of course, greatly appreciated.
@@ -51,13 +53,14 @@
 %   texindex foo.??
 %   tex foo.texi
 %   tex foo.texi
-%   dvips foo.dvi -o # or whatever, to process the dvi file; this makes foo.ps.
-% The extra runs of TeX get the cross-reference information correct.
+%   dvips foo.dvi -o  # or whatever; this makes foo.ps.
+% The extra TeX runs get the cross-reference information correct.
 % Sometimes one run after texindex suffices, and sometimes you need more
 % than two; texi2dvi does it as many times as necessary.
-%
-% It is possible to adapt texinfo.tex for other languages.  You can get
-% the existing language-specific files from ftp://ftp.gnu.org/gnu/texinfo/.
+% 
+% It is possible to adapt texinfo.tex for other languages, to some
+% extent.  You can get the existing language-specific files from the
+% full Texinfo distribution.
 
 \message{Loading texinfo [version \texinfoversion]:}
 
@@ -67,7 +70,14 @@
 \everyjob{\message{[Texinfo version \texinfoversion]}%
   \catcode`+=\active \catcode`\_=\active}
 
-% Save some parts of plain tex whose names we will redefine.
+\message{Basics,}
+\chardef\other=12
+
+% We never want plain's \outer definition of \+ in Texinfo.
+% For @tex, we can use \tabalign.
+\let\+ = \relax
+
+% Save some plain tex macros whose names we will redefine.
 \let\ptexb=\b
 \let\ptexbullet=\bullet
 \let\ptexc=\c
@@ -77,19 +87,17 @@
 \let\ptexend=\end
 \let\ptexequiv=\equiv
 \let\ptexexclam=\!
+\let\ptexgtr=>
+\let\ptexhat=^
 \let\ptexi=\i
 \let\ptexlbrace=\{
+\let\ptexless=<
+\let\ptexplus=+
 \let\ptexrbrace=\}
+\let\ptexslash=\/
 \let\ptexstar=\*
 \let\ptext=\t
 
-% We never want plain's outer \+ definition in Texinfo.
-% For @tex, we can use \tabalign.
-\let\+ = \relax
-
-\message{Basics,}
-\chardef\other=12
-
 % If this character appears in an error message or help string, it
 % starts a new line in the output.
 \newlinechar = `^^J
@@ -136,40 +144,75 @@
 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
 \ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi
 
+% In some macros, we cannot use the `\? notation---the left quote is
+% in some cases the escape char.
+\chardef\colonChar = `\:
+\chardef\commaChar = `\,
+\chardef\dotChar   = `\.
+\chardef\equalChar = `\=
+\chardef\exclamChar= `\!
+\chardef\questChar = `\?
+\chardef\semiChar  = `\;
+\chardef\spaceChar = `\ %
+\chardef\underChar = `\_
+
 % Ignore a token.
 %
 \def\gobble#1{}
 
+% True if #1 is the empty string, i.e., called like `\ifempty{}'.
+%
+\def\ifempty#1{\ifemptyx #1\emptymarkA\emptymarkB}%
+\def\ifemptyx#1#2\emptymarkB{\ifx #1\emptymarkA}%
+
+% Hyphenation fixes.
 \hyphenation{ap-pen-dix}
-\hyphenation{mini-buf-fer mini-buf-fers}
 \hyphenation{eshell}
+\hyphenation{mini-buf-fer mini-buf-fers}
+\hyphenation{time-stamp}
 \hyphenation{white-space}
 
 % Margin to add to right of even pages, to left of odd pages.
-\newdimen \bindingoffset
-\newdimen \normaloffset
+\newdimen\bindingoffset
+\newdimen\normaloffset
 \newdimen\pagewidth \newdimen\pageheight
 
 % Sometimes it is convenient to have everything in the transcript file
 % and nothing on the terminal.  We don't just call \tracingall here,
-% since that produces some useless output on the terminal.
+% since that produces some useless output on the terminal.  We also make
+% some effort to order the tracing commands to reduce output in the log
+% file; cf. trace.sty in LaTeX.
 %
 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
-\ifx\eTeXversion\undefined
-\def\loggingall{\tracingcommands2 \tracingstats2
-   \tracingpages1 \tracingoutput1 \tracinglostchars1
-   \tracingmacros2 \tracingparagraphs1 \tracingrestores1
-   \showboxbreadth\maxdimen\showboxdepth\maxdimen
-}%
-\else
-\def\loggingall{\tracingcommands3 \tracingstats2
-   \tracingpages1 \tracingoutput1 \tracinglostchars1
-   \tracingmacros2 \tracingparagraphs1 \tracingrestores1
-   \tracingscantokens1 \tracingassigns1 \tracingifs1
-   \tracinggroups1 \tracingnesting2
-   \showboxbreadth\maxdimen\showboxdepth\maxdimen
+\def\loggingall{%
+  \tracingstats2
+  \tracingpages1
+  \tracinglostchars2  % 2 gives us more in etex
+  \tracingparagraphs1
+  \tracingoutput1
+  \tracingmacros2
+  \tracingrestores1
+  \showboxbreadth\maxdimen \showboxdepth\maxdimen
+  \ifx\eTeXversion\undefined\else % etex gives us more logging
+    \tracingscantokens1
+    \tracingifs1
+    \tracinggroups1
+    \tracingnesting2
+    \tracingassigns1
+  \fi
+  \tracingcommands3  % 3 gives us more in etex
+  \errorcontextlines\maxdimen
 }%
-\fi
+
+% add check for \lastpenalty to plain's definitions.  If the last thing
+% we did was a \nobreak, we don't want to insert more space.
+% 
+\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
+  \removelastskip\penalty-50\smallskip\fi\fi}
+\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
+  \removelastskip\penalty-100\medskip\fi\fi}
+\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
+  \removelastskip\penalty-200\bigskip\fi\fi}
 
 % For @cropmarks command.
 % Do @cropmarks to get crop marks.
@@ -215,6 +258,9 @@
     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
                    % the page break happens to be in the middle of an example.
     \shipout\vbox{%
+      % Do this early so pdf references go to the beginning of the page.
+      \ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi
+      %
       \ifcropmarks \vbox to \outervsize\bgroup
         \hsize = \outerhsize
         \vskip-\topandbottommargin
@@ -244,8 +290,6 @@
         \unvbox\footlinebox
       \fi
       %
-      \ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi
-      %
       \ifcropmarks
           \egroup % end of \vbox\bgroup
         \hfil\egroup % end of (centering) \line\bgroup
@@ -263,7 +307,7 @@
       \egroup % \vbox from first cropmarks clause
       \fi
     }% end of \shipout\vbox
-  }% end of group with \turnoffactive
+  }% end of group with \normalturnoffactive
   \advancepageno
   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
 }
@@ -423,17 +467,6 @@
 }
 
 
-% Single-spacing is done by various environments (specifically, in
-% \nonfillstart and \quotations).
-\newskip\singlespaceskip \singlespaceskip = 12.5pt
-\def\singlespace{%
-  % Why was this kern here?  It messes up equalizing space above and below
-  % environments.  --karl, 6may93
-  %{\advance \baselineskip by -\singlespaceskip
-  %\kern \baselineskip}%
-  \setleading \singlespaceskip
-}
-
 %% Simple single-character @ commands
 
 % @@ prints an @
@@ -453,16 +486,19 @@
 \let\{=\mylbrace
 \let\}=\myrbrace
 \begingroup
-  % Definitions to produce actual \{ & \} command in an index.
-  \catcode`\{ = 12 \catcode`\} = 12
+  % Definitions to produce \{ and \} commands for indices,
+  % and @{ and @} for the aux file.
+  \catcode`\{ = \other \catcode`\} = \other
   \catcode`\[ = 1 \catcode`\] = 2
-  \catcode`\@ = 0 \catcode`\\ = 12
-  @gdef@lbracecmd[\{]%
-  @gdef@rbracecmd[\}]%
-@endgroup
+  \catcode`\! = 0 \catcode`\\ = \other
+  !gdef!lbracecmd[\{]%
+  !gdef!rbracecmd[\}]%
+  !gdef!lbraceatcmd[@{]%
+  !gdef!rbraceatcmd[@}]%
+!endgroup
 
 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
-% Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H.
+% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
 \let\, = \c
 \let\dotaccent = \.
 \def\ringaccent#1{{\accent23 #1}}
@@ -471,7 +507,7 @@
 \let\udotaccent = \d
 
 % Other special characters: @questiondown @exclamdown
-% Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss.
+% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
 \def\questiondown{?`}
 \def\exclamdown{!`}
 
@@ -504,6 +540,9 @@
 % @* forces a line break.
 \def\*{\hfil\break\hbox{}\ignorespaces}
 
+% @/ allows a line break.
+\let\/=\allowbreak
+
 % @. is an end-of-sentence period.
 \def\.{.\spacefactor=3000 }
 
@@ -526,6 +565,16 @@
 % therefore, no glue is inserted, and the space between the headline and
 % the text is small, which looks bad.
 %
+% Another complication is that the group might be very large.  This can
+% cause the glue on the previous page to be unduly stretched, because it
+% does not have much material.  In this case, it's better to add an
+% explicit \vfill so that the extra space is at the bottom.  The
+% threshold for doing this is if the group is more than \vfilllimit
+% percent of a page (\vfilllimit can be changed inside of @tex).
+% 
+\newbox\groupbox
+\def\vfilllimit{0.7}
+%
 \def\group{\begingroup
   \ifnum\catcode13=\active \else
     \errhelp = \groupinvalidhelp
@@ -539,10 +588,22 @@
   % above.  But it's pretty close.
   \def\Egroup{%
     \egroup           % End the \vtop.
+    % \dimen0 is the vertical size of the group's box.
+    \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
+    % \dimen2 is how much space is left on the page (more or less).
+    \dimen2 = \pageheight   \advance\dimen2 by -\pagetotal
+    % if the group doesn't fit on the current page, and it's a big big
+    % group, force a page break.
+    \ifdim \dimen0 > \dimen2
+      \ifdim \pagetotal < \vfilllimit\pageheight
+        \page
+      \fi
+    \fi
+    \copy\groupbox
     \endgroup         % End the \group.
   }%
   %
-  \vtop\bgroup
+  \setbox\groupbox = \vtop\bgroup
     % We have to put a strut on the last line in case the @group is in
     % the midst of an example, rather than completely enclosing it.
     % Otherwise, the interline space between the last line of the group
@@ -667,8 +728,7 @@ where each line of input produces a line of output.}
   \spacefactor=3000
 }
 
-
-% @page    forces the start of a new page
+% @page forces the start of a new page.
 %
 \def\page{\par\vfill\supereject}
 
@@ -688,44 +748,88 @@ where each line of input produces a line of output.}
 \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
 \leftline{\hskip\leftskip{\rm#1}}}}
 
-% @inmargin{TEXT} puts TEXT in the margin next to the current paragraph.
-
-\def\inmargin#1{%
-\strut\vadjust{\nobreak\kern-\strutdepth
-  \vtop to \strutdepth{\baselineskip\strutdepth\vss
-  \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}}
+% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
+% paragraph.  For more general purposes, use the \margin insertion
+% class.  WHICH is `l' or `r'.
+%
 \newskip\inmarginspacing \inmarginspacing=1cm
 \def\strutdepth{\dp\strutbox}
-
-%\hbox{{\rm#1}}\hfil\break}}
+%
+\def\doinmargin#1#2{\strut\vadjust{%
+  \nobreak
+  \kern-\strutdepth
+  \vtop to \strutdepth{%
+    \baselineskip=\strutdepth
+    \vss
+    % if you have multiple lines of stuff to put here, you'll need to
+    % make the vbox yourself of the appropriate size.
+    \ifx#1l%
+      \llap{\ignorespaces #2\hskip\inmarginspacing}%
+    \else
+      \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
+    \fi
+    \null
+  }%
+}}
+\def\inleftmargin{\doinmargin l}
+\def\inrightmargin{\doinmargin r}
+%
+% @inmargin{TEXT [, RIGHT-TEXT]}
+% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
+% else use TEXT for both).
+% 
+\def\inmargin#1{\parseinmargin #1,,\finish}
+\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
+  \setbox0 = \hbox{\ignorespaces #2}% 
+  \ifdim\wd0 > 0pt
+    \def\lefttext{#1}%  have both texts
+    \def\righttext{#2}%
+  \else
+    \def\lefttext{#1}%  have only one text
+    \def\righttext{#1}%
+  \fi
+  %
+  \ifodd\pageno
+    \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
+  \else
+    \def\temp{\inleftmargin\lefttext}%
+  \fi
+  \temp
+}
 
 % @include file    insert text of that file as input.
 % Allow normal characters that  we make active in the argument (a file name).
 \def\include{\begingroup
-  \catcode`\\=12
-  \catcode`~=12
-  \catcode`^=12
-  \catcode`_=12
-  \catcode`|=12
-  \catcode`<=12
-  \catcode`>=12
-  \catcode`+=12
+  \catcode`\\=\other
+  \catcode`~=\other
+  \catcode`^=\other
+  \catcode`_=\other
+  \catcode`|=\other
+  \catcode`<=\other
+  \catcode`>=\other
+  \catcode`+=\other
   \parsearg\includezzz}
 % Restore active chars for included file.
 \def\includezzz#1{\endgroup\begingroup
   % Read the included file in a group so nested @include's work.
   \def\thisfile{#1}%
+  \let\value=\expandablevalue
   \input\thisfile
 \endgroup}
 
 \def\thisfile{}
 
-% @center line   outputs that line, centered
-
-\def\center{\parsearg\centerzzz}
-\def\centerzzz #1{{\advance\hsize by -\leftskip
-\advance\hsize by -\rightskip
-\centerline{#1}}}
+% @center line
+% outputs that line, centered.
+%
+\def\center{\parsearg\docenter}
+\def\docenter#1{{%
+  \ifhmode \hfil\break \fi
+  \advance\hsize by -\leftskip
+  \advance\hsize by -\rightskip
+  \line{\hfil \ignorespaces#1\unskip \hfil}%
+  \ifhmode \break \fi
+}}
 
 % @sp n   outputs n lines of vertical space
 
@@ -785,18 +889,56 @@ where each line of input produces a line of output.}
 %
 \def\asis#1{#1}
 
-% @math means output in math mode.
-% We don't use $'s directly in the definition of \math because control
-% sequences like \math are expanded when the toc file is written.  Then,
-% we read the toc file back, the $'s will be normal characters (as they
-% should be, according to the definition of Texinfo).  So we must use a
-% control sequence to switch into and out of math mode.
+% @math outputs its argument in math mode.
+% We don't use $'s directly in the definition of \math because we need
+% to set catcodes according to plain TeX first, to allow for subscripts,
+% superscripts, special math chars, etc.
+% 
+\let\implicitmath = $%$ font-lock fix
 %
-% This isn't quite enough for @math to work properly in indices, but it
-% seems unlikely it will ever be needed there.
+% One complication: _ usually means subscripts, but it could also mean
+% an actual _ character, as in @math{@var{some_variable} + 1}.  So make
+% _ within @math be active (mathcode "8000), and distinguish by seeing
+% if the current family is \slfam, which is what @var uses.
+% 
+{\catcode\underChar = \active
+\gdef\mathunderscore{%
+  \catcode\underChar=\active
+  \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
+}}
 %
-\let\implicitmath = $
-\def\math#1{\implicitmath #1\implicitmath}
+% Another complication: we want \\ (and @\) to output a \ character.
+% FYI, plain.tex uses \\ as a temporary control sequence (why?), but
+% this is not advertised and we don't care.  Texinfo does not
+% otherwise define @\.
+% 
+% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
+\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
+%
+\def\math{%
+  \tex
+  \mathcode`\_="8000 \mathunderscore
+  \let\\ = \mathbackslash
+  \mathactive
+  \implicitmath\finishmath}
+\def\finishmath#1{#1\implicitmath\Etex}
+
+% Some active characters (such as <) are spaced differently in math.
+% We have to reset their definitions in case the @math was an
+% argument to a command which set the catcodes (such as @item or @section).
+% 
+{
+  \catcode`^ = \active
+  \catcode`< = \active
+  \catcode`> = \active
+  \catcode`+ = \active
+  \gdef\mathactive{%
+    \let^ = \ptexhat
+    \let< = \ptexless
+    \let> = \ptexgtr
+    \let+ = \ptexplus
+  }
+}
 
 % @bullet and @minus need the same treatment as @math, just above.
 \def\bullet{\implicitmath\ptexbullet\implicitmath}
@@ -879,20 +1021,26 @@ where each line of input produces a line of output.}
   \def\dopdfimage#1#2#3{%
     \def\imagewidth{#2}%
     \def\imageheight{#3}%
+    % without \immediate, pdftex seg faults when the same image is
+    % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
     \ifnum\pdftexversion < 14
-      \pdfimage
+      \immediate\pdfimage
     \else
-      \pdfximage
+      \immediate\pdfximage
     \fi
       \ifx\empty\imagewidth\else width \imagewidth \fi
       \ifx\empty\imageheight\else height \imageheight \fi
-      {#1.pdf}%
+      \ifnum\pdftexversion<13
+         #1.pdf%
+       \else
+         {#1.pdf}%
+       \fi
     \ifnum\pdftexversion < 14 \else
       \pdfrefximage \pdflastximage
     \fi}
-  \def\pdfmkdest#1{\pdfdest name{#1@} xyz}
-  \def\pdfmkpgn#1{#1@}
-  \let\linkcolor = \Cyan
+  \def\pdfmkdest#1{{\normalturnoffactive \pdfdest name{#1} xyz}}
+  \def\pdfmkpgn#1{#1}
+  \let\linkcolor = \Blue  % was Cyan, but that seems light?
   \def\endlink{\Black\pdfendlink}
   % Adding outlines to PDF; macros for calculating structure of outlines
   % come from Petr Olsak
@@ -903,41 +1051,43 @@ where each line of input produces a line of output.}
     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
   \def\pdfmakeoutlines{{%
     \openin 1 \jobname.toc
-    \ifeof 1\else\bgroup
+    \ifeof 1\else\begingroup
       \closein 1 
-      \indexnofonts
-      \def\tt{}
-      % thanh's hack / proper braces in bookmarks  
+      % Thanh's hack / proper braces in bookmarks  
       \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
       \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
       %
       \def\chapentry ##1##2##3{}
-      \def\unnumbchapentry ##1##2{}
       \def\secentry ##1##2##3##4{\advancenumber{chap##2}}
-      \def\unnumbsecentry ##1##2{}
       \def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}}
-      \def\unnumbsubsecentry ##1##2{}
       \def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}}
-      \def\unnumbsubsubsecentry ##1##2{}
+      \let\appendixentry = \chapentry
+      \let\unnumbchapentry = \chapentry
+      \let\unnumbsecentry = \secentry
+      \let\unnumbsubsecentry = \subsecentry
+      \let\unnumbsubsubsecentry = \subsubsecentry
       \input \jobname.toc
       \def\chapentry ##1##2##3{%
         \pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}}
-      \def\unnumbchapentry ##1##2{%
-        \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
       \def\secentry ##1##2##3##4{%
         \pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}}
-      \def\unnumbsecentry ##1##2{%
-        \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
       \def\subsecentry ##1##2##3##4##5{%
         \pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}}
-      \def\unnumbsubsecentry ##1##2{%
-        \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
       \def\subsubsecentry ##1##2##3##4##5##6{%
         \pdfoutline goto name{\pdfmkpgn{##6}}{##1}}
-      \def\unnumbsubsubsecentry ##1##2{%
-        \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
+      \let\appendixentry = \chapentry
+      \let\unnumbchapentry = \chapentry
+      \let\unnumbsecentry = \secentry
+      \let\unnumbsubsecentry = \subsecentry
+      \let\unnumbsubsubsecentry = \subsubsecentry
+      %
+      % Make special characters normal for writing to the pdf file.
+      % 
+      \indexnofonts
+      \let\tt=\relax
+      \turnoffactive
       \input \jobname.toc
-    \egroup\fi
+    \endgroup\fi
   }}
   \def\makelinks #1,{%
     \def\params{#1}\def\E{END}%
@@ -987,6 +1137,7 @@ where each line of input produces a line of output.}
   \def\pdfurl#1{%
     \begingroup
       \normalturnoffactive\def\@{@}%
+      \let\value=\expandablevalue
       \leavevmode\Red
       \startlink attr{/Border [0 0 0]}%
         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
@@ -1014,9 +1165,8 @@ where each line of input produces a line of output.}
   \def\makelink{\addtokens{\toksB}%
     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
   \def\pdflink#1{%
-    \startlink attr{/Border [0 0 0]} goto name{\mkpgn{#1}}
+    \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
     \linkcolor #1\endlink}
-  \def\mkpgn#1{#1@} 
   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
 \fi % \ifx\pdfoutput
 
@@ -1033,9 +1183,26 @@ where each line of input produces a line of output.}
 % We don't need math for this one.
 \def\ttsl{\tenttsl}
 
-% Use Computer Modern fonts at \magstephalf (11pt).
-\newcount\mainmagstep
-\mainmagstep=\magstephalf
+% Default leading.
+\newdimen\textleading  \textleading = 13.2pt
+
+% Set the baselineskip to #1, and the lineskip and strut size
+% correspondingly.  There is no deep meaning behind these magic numbers
+% used as factors; they just match (closely enough) what Knuth defined.
+%
+\def\lineskipfactor{.08333}
+\def\strutheightpercent{.70833}
+\def\strutdepthpercent {.29167}
+%
+\def\setleading#1{%
+  \normalbaselineskip = #1\relax
+  \normallineskip = \lineskipfactor\normalbaselineskip
+  \normalbaselines
+  \setbox\strutbox =\hbox{%
+    \vrule width0pt height\strutheightpercent\baselineskip
+                    depth \strutdepthpercent \baselineskip
+  }%
+}
 
 % Set the font macro #1 to the font named #2, adding on the
 % specified font prefix (normally `cm').
@@ -1055,27 +1222,34 @@ where each line of input produces a line of output.}
 \def\bxshape{bx}
 \def\ttshape{tt}
 \def\ttbshape{tt}
-\def\ttslshape{sltt}
+%\def\ttslshape{sltt} gmsh
+\def\ttslshape{ti}
 \def\itshape{ti}
 \def\itbshape{bxti}
-\def\slshape{sl}
-\def\slbshape{bxsl}
+%\def\slshape{sl} gmsh
+%\def\slbshape{bxsl} gmsh
+\def\slshape{ti}
+\def\slbshape{bxti}
 \def\sfshape{ss}
 \def\sfbshape{ss}
 \def\scshape{csc}
 \def\scbshape{csc}
 
+\newcount\mainmagstep
 \ifx\bigger\relax
-\let\mainmagstep=\magstep1
-\setfont\textrm\rmshape{12}{1000}
-\setfont\texttt\ttshape{12}{1000}
+  % not really supported.
+  \mainmagstep=\magstep1
+  \setfont\textrm\rmshape{12}{1000}
+  \setfont\texttt\ttshape{12}{1000}
 \else
-\setfont\textrm\rmshape{10}{\mainmagstep}
-\setfont\texttt\ttshape{10}{\mainmagstep}
+  \mainmagstep=\magstephalf
+  \setfont\textrm\rmshape{10}{\mainmagstep}
+  \setfont\texttt\ttshape{10}{\mainmagstep}
 \fi
-% Instead of cmb10, you many want to use cmbx10.
+% Instead of cmb10, you may want to use cmbx10.
 % cmbx10 is a prettier font on its own, but cmb10
-% looks better when embedded in a line with cmr10.
+% looks better when embedded in a line with cmr10
+% (in Bob's opinion).
 \setfont\textbf\bfshape{10}{\mainmagstep}
 \setfont\textit\itshape{10}{\mainmagstep}
 \setfont\textsl\slshape{10}{\mainmagstep}
@@ -1102,6 +1276,18 @@ where each line of input produces a line of output.}
 \font\smalli=cmmi9
 \font\smallsy=cmsy9
 
+% Fonts for small examples (8pt).
+\setfont\smallerrm\rmshape{8}{1000}
+\setfont\smallertt\ttshape{8}{1000}
+\setfont\smallerbf\bfshape{10}{800}
+\setfont\smallerit\itshape{8}{1000}
+\setfont\smallersl\slshape{8}{1000}
+\setfont\smallersf\sfshape{8}{1000}
+\setfont\smallersc\scshape{10}{800}
+\setfont\smallerttsl\ttslshape{10}{800}
+\font\smalleri=cmmi8
+\font\smallersy=cmsy8
+
 % Fonts for title page:
 \setfont\titlerm\rmbshape{12}{\magstep3}
 \setfont\titleit\itbshape{10}{\magstep4}
@@ -1114,6 +1300,7 @@ where each line of input produces a line of output.}
 \font\titlei=cmmi12 scaled \magstep3
 \font\titlesy=cmsy10 scaled \magstep4
 \def\authorrm{\secrm}
+\def\authortt{\sectt}
 
 % Chapter (and unnumbered) fonts (17.28pt).
 \setfont\chaprm\rmbshape{12}{\magstep2}
@@ -1139,20 +1326,6 @@ where each line of input produces a line of output.}
 \font\seci=cmmi12 scaled \magstep1
 \font\secsy=cmsy10 scaled \magstep2
 
-% \setfont\ssecrm\bxshape{10}{\magstep1}    % This size an font looked bad.
-% \setfont\ssecit\itshape{10}{\magstep1}    % The letters were too crowded.
-% \setfont\ssecsl\slshape{10}{\magstep1}
-% \setfont\ssectt\ttshape{10}{\magstep1}
-% \setfont\ssecsf\sfshape{10}{\magstep1}
-
-%\setfont\ssecrm\bfshape{10}{1315}      % Note the use of cmb rather than cmbx.
-%\setfont\ssecit\itshape{10}{1315}      % Also, the size is a little larger than
-%\setfont\ssecsl\slshape{10}{1315}      % being scaled magstep1.
-%\setfont\ssectt\ttshape{10}{1315}
-%\setfont\ssecsf\sfshape{10}{1315}
-
-%\let\ssecbf=\ssecrm
-
 % Subsection fonts (13.15pt).
 \setfont\ssecrm\rmbshape{12}{\magstephalf}
 \setfont\ssecit\itbshape{10}{1315}
@@ -1169,17 +1342,16 @@ where each line of input produces a line of output.}
 
 % In order for the font changes to affect most math symbols and letters,
 % we have to define the \textfont of the standard families.  Since
-% texinfo doesn't allow for producing subscripts and superscripts, we
-% don't bother to reset \scriptfont and \scriptscriptfont (which would
-% also require loading a lot more fonts).
+% texinfo doesn't allow for producing subscripts and superscripts except
+% in the main text, we don't bother to reset \scriptfont and
+% \scriptscriptfont (which would also require loading a lot more fonts).
 %
 \def\resetmathfonts{%
-  \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
-  \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
-  \textfont\ttfam = \tentt \textfont\sffam = \tensf
+  \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
+  \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
+  \textfont\ttfam=\tentt \textfont\sffam=\tensf
 }
 
-
 % The font-changing commands redefine the meanings of \tenSTYLE, instead
 % of just \STYLE.  We do this so that font changes will continue to work
 % in math mode, where it is the current \fam that is relevant in most
@@ -1190,7 +1362,7 @@ where each line of input produces a line of output.}
   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl
-  \resetmathfonts}
+  \resetmathfonts \setleading{\textleading}}
 \def\titlefonts{%
   \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
   \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
@@ -1219,7 +1391,32 @@ where each line of input produces a line of output.}
   \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
   \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
   \let\tenttsl=\smallttsl
-  \resetmathfonts \setleading{11pt}}
+  \resetmathfonts \setleading{10.5pt}}
+\def\smallerfonts{%
+  \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
+  \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
+  \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
+  \let\tenttsl=\smallerttsl
+  \resetmathfonts \setleading{9.5pt}}
+
+% Set the fonts to use with the @small... environments.
+\let\smallexamplefonts = \smallfonts
+
+% About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
+% can fit this many characters:
+%   8.5x11=86   smallbook=72  a4=90  a5=69
+% If we use \smallerfonts (8pt), then we can fit this many characters:
+%   8.5x11=90+  smallbook=80  a4=90+  a5=77
+% For me, subjectively, the few extra characters that fit aren't worth
+% the additional smallness of 8pt.  So I'm making the default 9pt.
+% 
+% By the way, for comparison, here's what fits with @example (10pt):
+%   8.5x11=71  smallbook=60  a4=75  a5=58
+% 
+% I wish we used A4 paper on this side of the Atlantic.
+% 
+% --karl, 24jan03.
+
 
 % Set up the default fonts, so we can use them for creating boxes.
 %
@@ -1236,6 +1433,7 @@ where each line of input produces a line of output.}
 \setfont\shortcontrm\rmshape{12}{1000}
 \setfont\shortcontbf\bxshape{12}{1000}
 \setfont\shortcontsl\slshape{12}{1000}
+\setfont\shortconttt\ttshape{12}{1000}
 
 %% Add scribe-like font environments, plus @l for inline lisp (usually sans
 %% serif) and @ii for TeX italic
@@ -1243,8 +1441,8 @@ where each line of input produces a line of output.}
 % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
 % unless the following character is such as not to need one.
 \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
-\def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx}
-\def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx}
+\def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx}
+\def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx}
 
 \let\i=\smartitalic
 \let\var=\smartslanted
@@ -1262,6 +1460,17 @@ where each line of input produces a line of output.}
 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
 \def\restorehyphenation{\hyphenchar\font = `- }
 
+% Set sfcode to normal for the chars that usually have another value.
+% Can't use plain's \frenchspacing because it uses the `\x notation, and
+% sometimes \x has an active definition that messes things up.
+% 
+\catcode`@=11
+  \def\frenchspacing{%
+    \sfcode\dotChar  =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
+    \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
+  }
+\catcode`@=\other
+
 \def\t#1{%
   {\tt \rawbackslash \frenchspacing #1}%
   \null
@@ -1333,11 +1542,19 @@ where each line of input produces a line of output.}
 
 \def\realdash{-}
 \def\codedash{-\discretionary{}{}{}}
-\def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}}
+\def\codeunder{%
+  % this is all so @math{@code{var_name}+1} can work.  In math mode, _
+  % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
+  % will therefore expand the active definition of _, which is us
+  % (inside @code that is), therefore an endless loop.
+  \ifusingtt{\ifmmode
+               \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
+             \else\normalunderscore \fi
+             \discretionary{}{}{}}%
+            {\_}%
+}
 \def\codex #1{\tclose{#1}\endgroup}
 
-%\let\exp=\tclose  %Was temporary
-
 % @kbd is like @code, except that if the argument is just one @key command,
 % then @kbd has no effect.
 
@@ -1353,15 +1570,17 @@ where each line of input produces a line of output.}
     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
   \else\ifx\arg\wordcode
     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
+  \else
+    \errhelp = \EMsimple
+    \errmessage{Unknown @kbdinputstyle `\arg'}%
   \fi\fi\fi
 }
 \def\worddistinct{distinct}
 \def\wordexample{example}
 \def\wordcode{code}
 
-% Default is kbdinputdistinct.  (Too much of a hassle to call the macro,
-% the catcodes are wrong for parsearg to work.)
-\gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}
+% Default is `distinct.'
+\kbdinputstyle distinct
 
 \def\xkey{\key}
 \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
@@ -1449,6 +1668,16 @@ where each line of input produces a line of output.}
 % @pounds{} is a sterling sign.
 \def\pounds{{\it\$}}
 
+% @registeredsymbol - R in a circle.  For now, only works in text size;
+% we'd have to redo the font mechanism to change the \scriptstyle and
+% \scriptscriptstyle font sizes to make it look right in headings.
+% Adapted from the plain.tex definition of \copyright.
+% 
+\def\registeredsymbol{%
+  $^{{\ooalign{\hfil\raise.07ex\hbox{$\scriptstyle\rm R$}\hfil\crcr\Orb}}%
+    }$%
+}
+
 
 \message{page headings,}
 
@@ -1475,7 +1704,8 @@ where each line of input produces a line of output.}
    \let\subtitlerm=\tenrm
    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
    %
-   \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
+   \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines
+                   \let\tt=\authortt}%
    %
    % Leave some space at the very top of the page.
    \vglue\titlepagetopglue
@@ -1522,6 +1752,10 @@ where each line of input produces a line of output.}
    \oldpage
    \endgroup
    %
+   % Need this before the \...aftertitlepage checks so that if they are
+   % in effect the toc pages will come out with page numbers.
+   \HEADINGSon
+   %
    % If they want short, they certainly want long too.
    \ifsetshortcontentsaftertitlepage
      \shortcontents
@@ -1535,10 +1769,6 @@ where each line of input produces a line of output.}
      \global\let\contents = \relax
      \global\let\shortcontents = \relax
    \fi
-   %
-   \ifpdf \pdfmakepagedesttrue \fi
-   %
-   \HEADINGSon
 }
 
 \def\finishtitlepage{%
@@ -1671,7 +1901,10 @@ where each line of input produces a line of output.}
 }
 
 % Subroutines used in generating headings
-% Produces Day Month Year style of output.
+% This produces Day Month Year style of output.
+% Only define if not already defined, in case a txi-??.tex file has set
+% up a different format (e.g., txi-cs.tex does this).
+\ifx\today\undefined
 \def\today{%
   \number\day\space
   \ifcase\month
@@ -1680,6 +1913,7 @@ where each line of input produces a line of output.}
   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
   \fi
   \space\number\year}
+\fi
 
 % @settitle line...  specifies the title of the document, for headings.
 % It generates no output of its own.
@@ -1752,10 +1986,18 @@ where each line of input produces a line of output.}
     % \parskip glue -- logically it's part of the @item we just started.
     \nobreak \vskip-\parskip
     %
-    % Stop a page break at the \parskip glue coming up.  Unfortunately
+    % Stop a page break at the \parskip glue coming up.  (Unfortunately
     % we can't prevent a possible page break at the following
-    % \baselineskip glue.
-    \nobreak
+    % \baselineskip glue.)  However, if what follows is an environment
+    % such as @example, there will be no \parskip glue; then
+    % the negative vskip we just would cause the example and the item to
+    % crash together.  So we use this bizarre value of 10001 as a signal
+    % to \aboveenvbreak to insert \parskip glue after all.
+    % (Possibly there are other commands that could be followed by
+    % @example which need the same treatment, but not section titles; or
+    % maybe section titles are the only special case and they should be
+    % penalty 10001...)
+    \penalty 10001
     \endgroup
     \itemxneedsnegativevskipfalse
   \else
@@ -1861,11 +2103,6 @@ where each line of input produces a line of output.}
 \def\itemcontents{#1}%
 \let\item=\itemizeitem}
 
-% Set sfcode to normal for the chars that usually have another value.
-% These are `.?!:;,'
-\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
-  \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
-
 % \splitoff TOKENS\endmark defines \first to be the first token in
 % TOKENS, and \rest to be the remainder.
 %
@@ -2087,8 +2324,8 @@ where each line of input produces a line of output.}
          \let\go\pickupwholefraction
       \else
          \global\advance\colcount by 1
-         \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator;
-                            % typically that is always in the input, anyway.
+         \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
+                   % separator; typically that is always in the input, anyway.
          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
       \fi
     \fi
@@ -2103,18 +2340,18 @@ where each line of input produces a line of output.}
   \go
 }
 
-% This used to have \hskip1sp.  But then the space in a template line is
-% not enough.  That is bad.  So let's go back to just & until we
-% encounter the problem it was intended to solve again.
-% --karl, nathan@acm.org, 20apr99.
-\def\tab{&}
-
 % @multitable ... @end multitable definitions:
 %
 \def\multitable{\parsearg\dotable}
 \def\dotable#1{\bgroup
   \vskip\parskip
-  \let\item\crcr
+  \let\item=\crcrwithfootnotes
+  % A \tab used to include \hskip1sp.  But then the space in a template
+  % line is not enough.  That is bad.  So let's go back to just & until
+  % we encounter the problem it was intended to solve again.  --karl,
+  % nathan@acm.org, 20apr99.
+  \let\tab=&%
+  \let\startfootins=\startsavedfootnote
   \tolerance=9500
   \hbadness=9500
   \setmultitablespacing
@@ -2122,7 +2359,11 @@ where each line of input produces a line of output.}
   \parindent=\multitableparindent
   \overfullrule=0pt
   \global\colcount=0
-  \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}%
+  \def\Emultitable{%
+    \global\setpercentfalse
+    \crcrwithfootnotes\crcr
+    \egroup\egroup
+  }%
   %
   % To parse everything between @multitable and @item:
   \setuptable#1 \endsetuptable
@@ -2211,6 +2452,25 @@ width0pt\relax} \fi
                                       %% than skip between lines in the table.
 \fi}
 
+% In case a @footnote appears inside an alignment, save the footnote
+% text to a box and make the \insert when a row of the table is
+% finished.  Otherwise, the insertion is lost, it never migrates to the
+% main vertical list.  --kasal, 22jan03.
+%
+\newbox\savedfootnotes
+%
+% \dotable \let's \startfootins to this, so that \dofootnote will call
+% it instead of starting the insertion right away.
+\def\startsavedfootnote{%
+  \global\setbox\savedfootnotes = \vbox\bgroup
+    \unvbox\savedfootnotes
+}
+\def\crcrwithfootnotes{%
+  \crcr
+  \ifvoid\savedfootnotes \else
+    \noalign{\insert\footins{\box\savedfootnotes}}%
+  \fi
+}
 
 \message{conditionals,}
 % Prevent errors for section commands.
@@ -2246,64 +2506,117 @@ width0pt\relax} \fi
 % and so want to turn off most commands, in case they are used
 % incorrectly.
 %
+% We use \empty instead of \relax for the @def... commands, so that \end
+% doesn't throw an error.  For instance:
+% @ignore
+% @deffn ...
+% @end deffn
+% @end ignore
+% 
+% The @end deffn is going to get expanded, because we're trying to allow
+% nested conditionals.  But we don't want to expand the actual @deffn,
+% since it might be syntactically correct and intended to be ignored.
+% Since \end checks for \relax, using \empty does not cause an error.
+% 
 \def\ignoremorecommands{%
   \let\defcodeindex = \relax
-  \let\defcv = \relax
-  \let\deffn = \relax
-  \let\deffnx = \relax
+  \let\defcv = \empty
+  \let\defcvx = \empty
+  \let\Edefcv = \empty
+  \let\deffn = \empty
+  \let\deffnx = \empty
+  \let\Edeffn = \empty
   \let\defindex = \relax
-  \let\defivar = \relax
-  \let\defmac = \relax
-  \let\defmethod = \relax
-  \let\defop = \relax
-  \let\defopt = \relax
-  \let\defspec = \relax
-  \let\deftp = \relax
-  \let\deftypefn = \relax
-  \let\deftypefun = \relax
-  \let\deftypeivar = \relax
-  \let\deftypeop = \relax
-  \let\deftypevar = \relax
-  \let\deftypevr = \relax
-  \let\defun = \relax
-  \let\defvar = \relax
-  \let\defvr = \relax
-  \let\ref = \relax
-  \let\xref = \relax
-  \let\printindex = \relax
-  \let\pxref = \relax
-  \let\settitle = \relax
-  \let\setchapternewpage = \relax
-  \let\setchapterstyle = \relax
-  \let\everyheading = \relax
+  \let\defivar = \empty
+  \let\defivarx = \empty
+  \let\Edefivar = \empty
+  \let\defmac = \empty
+  \let\defmacx = \empty
+  \let\Edefmac = \empty
+  \let\defmethod = \empty
+  \let\defmethodx = \empty
+  \let\Edefmethod = \empty
+  \let\defop = \empty
+  \let\defopx = \empty
+  \let\Edefop = \empty
+  \let\defopt = \empty
+  \let\defoptx = \empty
+  \let\Edefopt = \empty
+  \let\defspec = \empty
+  \let\defspecx = \empty
+  \let\Edefspec = \empty
+  \let\deftp = \empty
+  \let\deftpx = \empty
+  \let\Edeftp = \empty
+  \let\deftypefn = \empty
+  \let\deftypefnx = \empty
+  \let\Edeftypefn = \empty
+  \let\deftypefun = \empty
+  \let\deftypefunx = \empty
+  \let\Edeftypefun = \empty
+  \let\deftypeivar = \empty
+  \let\deftypeivarx = \empty
+  \let\Edeftypeivar = \empty
+  \let\deftypemethod = \empty
+  \let\deftypemethodx = \empty
+  \let\Edeftypemethod = \empty
+  \let\deftypeop = \empty
+  \let\deftypeopx = \empty
+  \let\Edeftypeop = \empty
+  \let\deftypevar = \empty
+  \let\deftypevarx = \empty
+  \let\Edeftypevar = \empty
+  \let\deftypevr = \empty
+  \let\deftypevrx = \empty
+  \let\Edeftypevr = \empty
+  \let\defun = \empty
+  \let\defunx = \empty
+  \let\Edefun = \empty
+  \let\defvar = \empty
+  \let\defvarx = \empty
+  \let\Edefvar = \empty
+  \let\defvr = \empty
+  \let\defvrx = \empty
+  \let\Edefvr = \empty
+  \let\clear = \relax
+  \let\down = \relax
+  \let\evenfooting = \relax
   \let\evenheading = \relax
-  \let\oddheading = \relax
   \let\everyfooting = \relax
-  \let\evenfooting = \relax
-  \let\oddfooting = \relax
+  \let\everyheading = \relax
   \let\headings = \relax
   \let\include = \relax
+  \let\item = \relax
   \let\lowersections = \relax
-  \let\down = \relax
+  \let\oddfooting = \relax
+  \let\oddheading = \relax
+  \let\printindex = \relax
+  \let\pxref = \relax
   \let\raisesections = \relax
-  \let\up = \relax
+  \let\ref = \relax
   \let\set = \relax
-  \let\clear = \relax
-  \let\item = \relax
+  \let\setchapternewpage = \relax
+  \let\setchapterstyle = \relax
+  \let\settitle = \relax
+  \let\up = \relax
+  \let\verbatiminclude = \relax
+  \let\xref = \relax
 }
 
-% Ignore @ignore ... @end ignore.
-%
-\def\ignore{\doignore{ignore}}
-
-% Ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu, and @direntry text.
+% Ignore @ignore, @ifhtml, @ifinfo, and the like.
 %
-\def\ifinfo{\doignore{ifinfo}}
+\def\direntry{\doignore{direntry}}
+\def\documentdescriptionword{documentdescription}
+\def\documentdescription{\doignore{documentdescription}}
+\def\html{\doignore{html}}
 \def\ifhtml{\doignore{ifhtml}}
+\def\ifinfo{\doignore{ifinfo}}
 \def\ifnottex{\doignore{ifnottex}}
-\def\html{\doignore{html}}
+\def\ifplaintext{\doignore{ifplaintext}}
+\def\ifxml{\doignore{ifxml}}
+\def\ignore{\doignore{ignore}}
 \def\menu{\doignore{menu}}
-\def\direntry{\doignore{direntry}}
+\def\xml{\doignore{xml}}
 
 % @dircategory CATEGORY  -- specify a category of the dir file
 % which this file should belong to.  Ignore this in TeX.
@@ -2321,7 +2634,7 @@ width0pt\relax} \fi
   \long\def\doignoretext##1@end #1{\enddoignore}%
   %
   % Make sure that spaces turn into tokens that match what \doignoretext wants.
-  \catcode32 = 10
+  \catcode\spaceChar = 10
   %
   % Ignore braces, too, so mismatched braces don't cause trouble.
   \catcode`\{ = 9
@@ -2330,14 +2643,21 @@ width0pt\relax} \fi
   % We must not have @c interpreted as a control sequence.
   \catcode`\@ = 12
   %
-  % Make the letter c a comment character so that the rest of the line
-  % will be ignored. This way, the document can have (for example)
-  %   @c @end ifinfo
-  % and the @end ifinfo will be properly ignored.
-  % (We've just changed @ to catcode 12.)
-  \catcode`\c = 14
+  \def\ignoreword{#1}%
+  \ifx\ignoreword\documentdescriptionword
+    % The c kludge breaks documentdescription, since
+    % `documentdescription' contains a `c'.  Means not everything will
+    % be ignored inside @documentdescription, but oh well...
+  \else
+    % Make the letter c a comment character so that the rest of the line
+    % will be ignored. This way, the document can have (for example)
+    %   @c @end ifinfo
+    % and the @end ifinfo will be properly ignored.
+    % (We've just changed @ to catcode 12.)
+    \catcode`\c = 14
+  \fi
   %
-  % And now expand that command.
+  % And now expand the command defined above.
   \doignoretext
 }
 
@@ -2356,7 +2676,7 @@ width0pt\relax} \fi
     \immediate\write16{If you are running another version of TeX, relax.}
     \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
     \immediate\write16{  Then upgrade your TeX installation if you can.}
-    \immediate\write16{  (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)}
+    \immediate\write16{  (See ftp://ftp.gnu.org/non-gnu/TeX.README.)}
     \immediate\write16{If you are stuck with version 3.0, run the}
     \immediate\write16{  script ``tex3patch'' from the Texinfo distribution}
     \immediate\write16{  to use a workaround.}
@@ -2378,8 +2698,8 @@ width0pt\relax} \fi
   % We must actually expand the ignored text to look for the @end
   % command, so that nested ignore constructs work.  Thus, we put the
   % text into a \vbox and then do nothing with the result.  To minimize
-  % the change of memory overflow, we follow the approach outlined on
-  % page 401 of the TeXbook: make the current font be a dummy font.
+  % the chance of memory overflow, we follow the approach outlined on
+  % page 401 of the TeXbook.
   %
   \setbox0 = \vbox\bgroup
     % Don't complain about control sequences we have declared \outer.
@@ -2400,8 +2720,8 @@ width0pt\relax} \fi
     %
     % Set the current font to be \nullfont, a TeX primitive, and define
     % all the font commands to also use \nullfont.  We don't use
-    % dummy.tfm, as suggested in the TeXbook, because not all sites
-    % might have that installed.  Therefore, math mode will still
+    % dummy.tfm, as suggested in the TeXbook, because some sites
+    % might not have that installed.  Therefore, math mode will still
     % produce output, but that should be an extremely small amount of
     % stuff compared to the main input.
     %
@@ -2409,10 +2729,14 @@ width0pt\relax} \fi
     \let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont
     \let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont
     \let\tensf=\nullfont
-    % Similarly for index fonts (mostly for their use in smallexample).
+    % Similarly for index fonts.
     \let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont
     \let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont
     \let\smallsf=\nullfont
+    % Similarly for smallexample fonts.
+    \let\smallerrm=\nullfont \let\smallerit=\nullfont \let\smallersl=\nullfont
+    \let\smallerbf=\nullfont \let\smallertt=\nullfont \let\smallersc=\nullfont
+    \let\smallersf=\nullfont
     %
     % Don't complain when characters are missing from the fonts.
     \tracinglostchars = 0
@@ -2426,7 +2750,7 @@ width0pt\relax} \fi
     % Do minimal line-breaking.
     \pretolerance = 10000
     %
-    % Do not execute instructions in @tex
+    % Do not execute instructions in @tex.
     \def\tex{\doignore{tex}}%
     % Do not execute macro definitions.
     % `c' is a comment character, so the word `macro' will get cut off.
@@ -2471,7 +2795,7 @@ width0pt\relax} \fi
   % we're called from @code, as @code{@value{foo-bar_}}.  So \let any
   % such active characters to their normal equivalents.
   \gdef\value{\begingroup
-    \catcode`\-=12 \catcode`\_=12
+    \catcode`\-=\other \catcode`\_=\other
     \indexbreaks \let_\normalunderscore
     \valuexxx}
 }
@@ -2480,15 +2804,17 @@ width0pt\relax} \fi
 % We have this subroutine so that we can handle at least some @value's
 % properly in indexes (we \let\value to this in \indexdummies).  Ones
 % whose names contain - or _ still won't work, but we can't do anything
-% about that.  The command has to be fully expandable, since the result
-% winds up in the index file.  This means that if the variable's value
-% contains other Texinfo commands, it's almost certain it will fail
-% (although perhaps we could fix that with sufficient work to do a
-% one-level expansion on the result, instead of complete).
+% about that.  The command has to be fully expandable (if the variable
+% is set), since the result winds up in the index file.  This means that
+% if the variable's value contains other Texinfo commands, it's almost
+% certain it will fail (although perhaps we could fix that with
+% sufficient work to do a one-level expansion on the result, instead of
+% complete).
 %
 \def\expandablevalue#1{%
   \expandafter\ifx\csname SET#1\endcsname\relax
     {[No value for ``#1'']}%
+    \message{Variable `#1', used in @value, is not set.}%
   \else
     \csname SET#1\endcsname
   \fi
@@ -2497,13 +2823,14 @@ width0pt\relax} \fi
 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
 % with @set.
 %
-\def\ifset{\parsearg\ifsetxxx}
-\def\ifsetxxx #1{%
+\def\ifset{\parsearg\doifset}
+\def\doifset#1{%
   \expandafter\ifx\csname SET#1\endcsname\relax
-    \expandafter\ifsetfail
+    \let\next=\ifsetfail
   \else
-    \expandafter\ifsetsucceed
+    \let\next=\ifsetsucceed
   \fi
+  \next
 }
 \def\ifsetsucceed{\conditionalsucceed{ifset}}
 \def\ifsetfail{\nestedignore{ifset}}
@@ -2512,51 +2839,39 @@ width0pt\relax} \fi
 % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
 % defined with @set, or has been undefined with @clear.
 %
-\def\ifclear{\parsearg\ifclearxxx}
-\def\ifclearxxx #1{%
+\def\ifclear{\parsearg\doifclear}
+\def\doifclear#1{%
   \expandafter\ifx\csname SET#1\endcsname\relax
-    \expandafter\ifclearsucceed
+    \let\next=\ifclearsucceed
   \else
-    \expandafter\ifclearfail
+    \let\next=\ifclearfail
   \fi
+  \next
 }
 \def\ifclearsucceed{\conditionalsucceed{ifclear}}
 \def\ifclearfail{\nestedignore{ifclear}}
 \defineunmatchedend{ifclear}
 
-% @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text
-% following, through the first @end iftex (etc.).  Make `@end iftex'
-% (etc.) valid only after an @iftex.
+% @iftex, @ifnothtml, @ifnotinfo, @ifnotplaintext always succeed; we
+% read the text following, through the first @end iftex (etc.).  Make
+% `@end iftex' (etc.) valid only after an @iftex.
 %
 \def\iftex{\conditionalsucceed{iftex}}
 \def\ifnothtml{\conditionalsucceed{ifnothtml}}
 \def\ifnotinfo{\conditionalsucceed{ifnotinfo}}
+\def\ifnotplaintext{\conditionalsucceed{ifnotplaintext}}
 \defineunmatchedend{iftex}
 \defineunmatchedend{ifnothtml}
 \defineunmatchedend{ifnotinfo}
+\defineunmatchedend{ifnotplaintext}
 
-% We can't just want to start a group at @iftex (for example) and end it
-% at @end iftex, since then @set commands inside the conditional have no
-% effect (they'd get reverted at the end of the group).  So we must
-% define \Eiftex to redefine itself to be its previous value.  (We can't
-% just define it to fail again with an ``unmatched end'' error, since
-% the @ifset might be nested.)
-%
-\def\conditionalsucceed#1{%
-  \edef\temp{%
-    % Remember the current value of \E#1.
-    \let\nece{prevE#1} = \nece{E#1}%
-    %
-    % At the `@end #1', redefine \E#1 to be its previous value.
-    \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
-  }%
-  \temp
-}
-
-% We need to expand lots of \csname's, but we don't want to expand the
-% control sequences after we've constructed them.
+% True conditional.  Since \set globally defines its variables, we can
+% just start and end a group (to keep the @end definition undefined at
+% the outer level).
 %
-\def\nece#1{\expandafter\noexpand\csname#1\endcsname}
+\def\conditionalsucceed#1{\begingroup
+  \expandafter\def\csname E#1\endcsname{\endgroup}%
+}
 
 % @defininfoenclose.
 \let\definfoenclose=\comment
@@ -2588,42 +2903,48 @@ width0pt\relax} \fi
 }
 
 % @defindex foo  ==  \newindex{foo}
-
+%
 \def\defindex{\parsearg\newindex}
 
 % Define @defcodeindex, like @defindex except put all entries in @code.
-
+%
+\def\defcodeindex{\parsearg\newcodeindex}
+%
 \def\newcodeindex#1{%
   \iflinks
     \expandafter\newwrite \csname#1indfile\endcsname
     \openout \csname#1indfile\endcsname \jobname.#1
   \fi
   \expandafter\xdef\csname#1index\endcsname{%
-    \noexpand\docodeindex{#1}}
+    \noexpand\docodeindex{#1}}%
 }
 
-\def\defcodeindex{\parsearg\newcodeindex}
 
 % @synindex foo bar    makes index foo feed into index bar.
 % Do this instead of @defindex foo if you don't want it as a separate index.
-% The \closeout helps reduce unnecessary open files; the limit on the
-% Acorn RISC OS is a mere 16 files.
-\def\synindex#1 #2 {%
-  \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
-  \expandafter\closeout\csname#1indfile\endcsname
-  \expandafter\let\csname#1indfile\endcsname=\synindexfoo
-  \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
-    \noexpand\doindex{#2}}%
-}
-
+% 
 % @syncodeindex foo bar   similar, but put all entries made for index foo
 % inside @code.
-\def\syncodeindex#1 #2 {%
-  \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
-  \expandafter\closeout\csname#1indfile\endcsname
-  \expandafter\let\csname#1indfile\endcsname=\synindexfoo
-  \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
-    \noexpand\docodeindex{#2}}%
+% 
+\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
+\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
+
+% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
+% #3 the target index (bar).
+\def\dosynindex#1#2#3{%
+  % Only do \closeout if we haven't already done it, else we'll end up
+  % closing the target index.
+  \expandafter \ifx\csname donesynindex#2\endcsname \undefined
+    % The \closeout helps reduce unnecessary open files; the limit on the
+    % Acorn RISC OS is a mere 16 files.
+    \expandafter\closeout\csname#2indfile\endcsname
+    \expandafter\let\csname\donesynindex#2\endcsname = 1
+  \fi
+  % redefine \fooindfile:
+  \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
+  \expandafter\let\csname#2indfile\endcsname=\temp
+  % redefine \fooindex:
+  \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
 }
 
 % Define \doindex, the driver for all \fooindex macros.
@@ -2643,171 +2964,254 @@ width0pt\relax} \fi
 \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
 \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
 
+% Take care of Texinfo commands that can appear in an index entry.
+% Since there are some commands we want to expand, and others we don't,
+% we have to laboriously prevent expansion for those that we don't.
+% 
 \def\indexdummies{%
-\def\ { }%
-% Take care of the plain tex accent commands.
-\def\"{\realbackslash "}%
-\def\`{\realbackslash `}%
-\def\'{\realbackslash '}%
-\def\^{\realbackslash ^}%
-\def\~{\realbackslash ~}%
-\def\={\realbackslash =}%
-\def\b{\realbackslash b}%
-\def\c{\realbackslash c}%
-\def\d{\realbackslash d}%
-\def\u{\realbackslash u}%
-\def\v{\realbackslash v}%
-\def\H{\realbackslash H}%
-% Take care of the plain tex special European modified letters.
-\def\oe{\realbackslash oe}%
-\def\ae{\realbackslash ae}%
-\def\aa{\realbackslash aa}%
-\def\OE{\realbackslash OE}%
-\def\AE{\realbackslash AE}%
-\def\AA{\realbackslash AA}%
-\def\o{\realbackslash o}%
-\def\O{\realbackslash O}%
-\def\l{\realbackslash l}%
-\def\L{\realbackslash L}%
-\def\ss{\realbackslash ss}%
-% Take care of texinfo commands likely to appear in an index entry.
-% (Must be a way to avoid doing expansion at all, and thus not have to
-% laboriously list every single command here.)
-\def\@{@}% will be @@ when we switch to @ as escape char.
-% Need these in case \tex is in effect and \{ is a \delimiter again.
-% But can't use \lbracecmd and \rbracecmd because texindex assumes
-% braces and backslashes are used only as delimiters.  
-\let\{ = \mylbrace
-\let\} = \myrbrace
-\def\_{{\realbackslash _}}%
-\def\w{\realbackslash w }%
-\def\bf{\realbackslash bf }%
-%\def\rm{\realbackslash rm }%
-\def\sl{\realbackslash sl }%
-\def\sf{\realbackslash sf}%
-\def\tt{\realbackslash tt}%
-\def\gtr{\realbackslash gtr}%
-\def\less{\realbackslash less}%
-\def\hat{\realbackslash hat}%
-\def\TeX{\realbackslash TeX}%
-\def\dots{\realbackslash dots }%
-\def\result{\realbackslash result}%
-\def\equiv{\realbackslash equiv}%
-\def\expansion{\realbackslash expansion}%
-\def\print{\realbackslash print}%
-\def\error{\realbackslash error}%
-\def\point{\realbackslash point}%
-\def\copyright{\realbackslash copyright}%
-\def\tclose##1{\realbackslash tclose {##1}}%
-\def\code##1{\realbackslash code {##1}}%
-\def\uref##1{\realbackslash uref {##1}}%
-\def\url##1{\realbackslash url {##1}}%
-\def\env##1{\realbackslash env {##1}}%
-\def\command##1{\realbackslash command {##1}}%
-\def\option##1{\realbackslash option {##1}}%
-\def\dotless##1{\realbackslash dotless {##1}}%
-\def\samp##1{\realbackslash samp {##1}}%
-\def\,##1{\realbackslash ,{##1}}%
-\def\t##1{\realbackslash t {##1}}%
-\def\r##1{\realbackslash r {##1}}%
-\def\i##1{\realbackslash i {##1}}%
-\def\b##1{\realbackslash b {##1}}%
-\def\sc##1{\realbackslash sc {##1}}%
-\def\cite##1{\realbackslash cite {##1}}%
-\def\key##1{\realbackslash key {##1}}%
-\def\file##1{\realbackslash file {##1}}%
-\def\var##1{\realbackslash var {##1}}%
-\def\kbd##1{\realbackslash kbd {##1}}%
-\def\dfn##1{\realbackslash dfn {##1}}%
-\def\emph##1{\realbackslash emph {##1}}%
-\def\acronym##1{\realbackslash acronym {##1}}%
-%
-% Handle some cases of @value -- where the variable name does not
-% contain - or _, and the value does not contain any
-% (non-fully-expandable) commands.
-\let\value = \expandablevalue
-%
-\unsepspaces
-% Turn off macro expansion
-\turnoffmacros
+  \def\@{@}% change to @@ when we switch to @ as escape char in index files.
+  \def\ {\realbackslash\space }%
+  % Need these in case \tex is in effect and \{ is a \delimiter again.
+  % But can't use \lbracecmd and \rbracecmd because texindex assumes
+  % braces and backslashes are used only as delimiters.  
+  \let\{ = \mylbrace
+  \let\} = \myrbrace
+  %
+  % \definedummyword defines \#1 as \realbackslash #1\space, thus
+  % effectively preventing its expansion.  This is used only for control
+  % words, not control letters, because the \space would be incorrect
+  % for control characters, but is needed to separate the control word
+  % from whatever follows.
+  % 
+  % For control letters, we have \definedummyletter, which omits the
+  % space.
+  % 
+  % These can be used both for control words that take an argument and
+  % those that do not.  If it is followed by {arg} in the input, then
+  % that will dutifully get written to the index (or wherever).
+  % 
+  \def\definedummyword##1{%
+    \expandafter\def\csname ##1\endcsname{\realbackslash ##1\space}%
+  }%
+  \def\definedummyletter##1{%
+    \expandafter\def\csname ##1\endcsname{\realbackslash ##1}%
+  }%
+  %
+  % Do the redefinitions.
+  \commondummies
+}
+
+% For the aux file, @ is the escape character.  So we want to redefine
+% everything using @ instead of \realbackslash.  When everything uses 
+% @, this will be simpler.
+% 
+\def\atdummies{%
+  \def\@{@@}%
+  \def\ {@ }%
+  \let\{ = \lbraceatcmd
+  \let\} = \rbraceatcmd
+  %
+  % (See comments in \indexdummies.)
+  \def\definedummyword##1{%
+    \expandafter\def\csname ##1\endcsname{@##1\space}%
+  }%
+  \def\definedummyletter##1{%
+    \expandafter\def\csname ##1\endcsname{@##1}%
+  }%
+  %
+  % Do the redefinitions.
+  \commondummies
+}
+
+% Called from \indexdummies and \atdummies.  \definedummyword and
+% \definedummyletter must be defined first.
+% 
+\def\commondummies{%
+  %
+  \normalturnoffactive
+  %
+  % Control letters and accents.
+  \definedummyletter{_}%
+  \definedummyletter{,}%
+  \definedummyletter{"}%
+  \definedummyletter{`}%
+  \definedummyletter{'}%
+  \definedummyletter{^}%
+  \definedummyletter{~}%
+  \definedummyletter{=}%
+  \definedummyword{u}%
+  \definedummyword{v}%
+  \definedummyword{H}%
+  \definedummyword{dotaccent}%
+  \definedummyword{ringaccent}%
+  \definedummyword{tieaccent}%
+  \definedummyword{ubaraccent}%
+  \definedummyword{udotaccent}%
+  \definedummyword{dotless}%
+  %
+  % Other non-English letters.
+  \definedummyword{AA}%
+  \definedummyword{AE}%
+  \definedummyword{L}%
+  \definedummyword{OE}%
+  \definedummyword{O}%
+  \definedummyword{aa}%
+  \definedummyword{ae}%
+  \definedummyword{l}%
+  \definedummyword{oe}%
+  \definedummyword{o}%
+  \definedummyword{ss}%
+  %
+  % Although these internal commands shouldn't show up, sometimes they do.
+  \definedummyword{bf}%
+  \definedummyword{gtr}%
+  \definedummyword{hat}%
+  \definedummyword{less}%
+  \definedummyword{sf}%
+  \definedummyword{sl}%
+  \definedummyword{tclose}%
+  \definedummyword{tt}%
+  %
+  % Texinfo font commands.
+  \definedummyword{b}%
+  \definedummyword{i}%
+  \definedummyword{r}%
+  \definedummyword{sc}%
+  \definedummyword{t}%
+  %
+  \definedummyword{TeX}%
+  \definedummyword{acronym}%
+  \definedummyword{cite}%
+  \definedummyword{code}%
+  \definedummyword{command}%
+  \definedummyword{dfn}%
+  \definedummyword{dots}%
+  \definedummyword{emph}%
+  \definedummyword{env}%
+  \definedummyword{file}%
+  \definedummyword{kbd}%
+  \definedummyword{key}%
+  \definedummyword{math}%
+  \definedummyword{option}%
+  \definedummyword{samp}%
+  \definedummyword{strong}%
+  \definedummyword{uref}%
+  \definedummyword{url}%
+  \definedummyword{var}%
+  \definedummyword{w}%
+  %
+  % Assorted special characters.
+  \definedummyword{bullet}%
+  \definedummyword{copyright}%
+  \definedummyword{dots}%
+  \definedummyword{enddots}%
+  \definedummyword{equiv}%
+  \definedummyword{error}%
+  \definedummyword{expansion}%
+  \definedummyword{minus}%
+  \definedummyword{pounds}%
+  \definedummyword{point}%
+  \definedummyword{print}%
+  \definedummyword{result}%
+  %
+  % Handle some cases of @value -- where the variable name does not
+  % contain - or _, and the value does not contain any
+  % (non-fully-expandable) commands.
+  \let\value = \expandablevalue
+  %
+  % Normal spaces, not active ones.
+  \unsepspaces
+  %
+  % No macro expansion.
+  \turnoffmacros
 }
 
 % If an index command is used in an @example environment, any spaces
 % therein should become regular spaces in the raw index file, not the
-% expansion of \tie (\\leavevmode \penalty \@M \ ).
+% expansion of \tie (\leavevmode \penalty \@M \ ).
 {\obeyspaces
  \gdef\unsepspaces{\obeyspaces\let =\space}}
 
-% \indexnofonts no-ops all font-change commands.
-% This is used when outputting the strings to sort the index by.
-\def\indexdummyfont#1{#1}
+
+% \indexnofonts is used when outputting the strings to sort the index
+% by, and when constructing control sequence names.  It eliminates all
+% control sequences and just writes whatever the best ASCII sort string
+% would be for a given command (usually its argument).
+%
 \def\indexdummytex{TeX}
 \def\indexdummydots{...}
-
+%
 \def\indexnofonts{%
-% Just ignore accents.
-\let\,=\indexdummyfont
-\let\"=\indexdummyfont
-\let\`=\indexdummyfont
-\let\'=\indexdummyfont
-\let\^=\indexdummyfont
-\let\~=\indexdummyfont
-\let\==\indexdummyfont
-\let\b=\indexdummyfont
-\let\c=\indexdummyfont
-\let\d=\indexdummyfont
-\let\u=\indexdummyfont
-\let\v=\indexdummyfont
-\let\H=\indexdummyfont
-\let\dotless=\indexdummyfont
-% Take care of the plain tex special European modified letters.
-\def\oe{oe}%
-\def\ae{ae}%
-\def\aa{aa}%
-\def\OE{OE}%
-\def\AE{AE}%
-\def\AA{AA}%
-\def\o{o}%
-\def\O{O}%
-\def\l{l}%
-\def\L{L}%
-\def\ss{ss}%
-\let\w=\indexdummyfont
-\let\t=\indexdummyfont
-\let\r=\indexdummyfont
-\let\i=\indexdummyfont
-\let\b=\indexdummyfont
-\let\emph=\indexdummyfont
-\let\strong=\indexdummyfont
-\let\cite=\indexdummyfont
-\let\sc=\indexdummyfont
-%Don't no-op \tt, since it isn't a user-level command
-% and is used in the definitions of the active chars like <, >, |...
-%\let\tt=\indexdummyfont
-\let\tclose=\indexdummyfont
-\let\code=\indexdummyfont
-\let\url=\indexdummyfont
-\let\uref=\indexdummyfont
-\let\env=\indexdummyfont
-\let\acronym=\indexdummyfont
-\let\command=\indexdummyfont
-\let\option=\indexdummyfont
-\let\file=\indexdummyfont
-\let\samp=\indexdummyfont
-\let\kbd=\indexdummyfont
-\let\key=\indexdummyfont
-\let\var=\indexdummyfont
-\let\TeX=\indexdummytex
-\let\dots=\indexdummydots
-\def\@{@}%
-}
-
-% To define \realbackslash, we must make \ not be an escape.
-% We must first make another character (@) an escape
-% so we do not become unable to do a definition.
-
-{\catcode`\@=0 \catcode`\\=\other
- @gdef@realbackslash{\}}
+  \def\ { }%
+  \def\@{@}%
+  % how to handle braces?
+  \def\_{\normalunderscore}%
+  %
+  \let\,=\asis
+  \let\"=\asis
+  \let\`=\asis
+  \let\'=\asis
+  \let\^=\asis
+  \let\~=\asis
+  \let\==\asis
+  \let\u=\asis
+  \let\v=\asis
+  \let\H=\asis
+  \let\dotaccent=\asis
+  \let\ringaccent=\asis
+  \let\tieaccent=\asis
+  \let\ubaraccent=\asis
+  \let\udotaccent=\asis
+  \let\dotless=\asis
+  %
+  % Other non-English letters.
+  \def\AA{AA}%
+  \def\AE{AE}%
+  \def\L{L}%
+  \def\OE{OE}%
+  \def\O{O}%
+  \def\aa{aa}%
+  \def\ae{ae}%
+  \def\l{l}%
+  \def\oe{oe}%
+  \def\o{o}%
+  \def\ss{ss}%
+  \def\exclamdown{!}%
+  \def\questiondown{?}%
+  %
+  % Don't no-op \tt, since it isn't a user-level command
+  % and is used in the definitions of the active chars like <, >, |, etc.
+  % Likewise with the other plain tex font commands.
+  %\let\tt=\asis
+  %
+  % Texinfo font commands.
+  \let\b=\asis
+  \let\i=\asis
+  \let\r=\asis
+  \let\sc=\asis
+  \let\t=\asis
+  %
+  \let\TeX=\indexdummytex
+  \let\acronym=\asis
+  \let\cite=\asis
+  \let\code=\asis
+  \let\command=\asis
+  \let\dfn=\asis
+  \let\dots=\indexdummydots
+  \let\emph=\asis
+  \let\env=\asis
+  \let\file=\asis
+  \let\kbd=\asis
+  \let\key=\asis
+  \let\math=\asis
+  \let\option=\asis
+  \let\samp=\asis
+  \let\strong=\asis
+  \let\uref=\asis
+  \let\url=\asis
+  \let\var=\asis
+  \let\w=\asis
+}
 
 \let\indexbackslash=0  %overridden during \printindex.
 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
@@ -2839,32 +3243,29 @@ width0pt\relax} \fi
         \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
         % so it will be output as is; and it will print as backslash.
         %
-        \def\thirdarg{#3}%
-        %
-        % If third arg is present, precede it with space in sort key.
-        \ifx\thirdarg\emptymacro
-          \let\subentry = \empty
-        \else
-          \def\subentry{ #3}%
-        \fi
-        %
-        % First process the index entry with all font commands turned
-        % off to get the string to sort by.
-        {\indexnofonts \xdef\indexsorttmp{#2\subentry}}%
-        %
-        % Now the real index entry with the fonts.
+        % The main index entry text.
         \toks0 = {#2}%
         %
-        % If third (subentry) arg is present, add it to the index
-        % string.  And include a space.
+        % If third arg is present, precede it with space in sort key.
+        \def\thirdarg{#3}%
         \ifx\thirdarg\emptymacro \else
+           % If the third (subentry) arg is present, add it to the index
+           % line to write.
           \toks0 = \expandafter{\the\toks0 \space #3}%
         \fi
         %
-        % Set up the complete index entry, with both the sort key
-        % and the original text, including any font commands.  We write
-        % three arguments to \entry to the .?? file, texindex reduces to
-        % two when writing the .??s sorted result.
+        % Process the index entry with all font commands turned off, to
+        % get the string to sort by.
+        {\indexnofonts
+         \edef\temp{\the\toks0}% need full expansion
+         \xdef\indexsorttmp{\temp}%
+        }%
+        %
+        % Set up the complete index entry, with both the sort key and
+        % the original text, including any font commands.  We write
+        % three arguments to \entry to the .?? file (four in the
+        % subentry case), texindex reduces to two when writing the .??s
+        % sorted result.
         \edef\temp{%
           \write\csname#1indfile\endcsname{%
             \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
@@ -2890,12 +3291,11 @@ width0pt\relax} \fi
         \iflinks
           \ifvmode
             \skip0 = \lastskip
-            \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi
+            \ifdim\lastskip = 0pt \else \nobreak\vskip-\skip0 \fi
           \fi
           %
           \temp % do the write
           %
-          %
           \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
         \fi
       }%
@@ -3037,7 +3437,7 @@ width0pt\relax} \fi
   %
   % \hangafter is reset to 1 (which is the value we want) at the start
   % of each paragraph, so we need not do anything with that.
-  \hangindent = 4pc %geuz 2em
+  \hangindent = 4pc %gmsh 2em
   %
   % When the entry text needs to be broken, just fill out the first line
   % with blank space.
@@ -3086,11 +3486,18 @@ width0pt\relax} \fi
 \def\primary #1{\line{#1\hfil}}
 
 \newskip\secondaryindent \secondaryindent=0.5cm
-
-\def\secondary #1#2{
-{\parfillskip=0in \parskip=0in
-\hangindent =1in \hangafter=1
-\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
+\def\secondary#1#2{{%
+  \parfillskip=0in
+  \parskip=0in
+  \hangindent=1in
+  \hangafter=1
+  \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
+  \ifpdf
+    \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
+  \else
+    #2
+  \fi
+  \par
 }}
 
 % Define two-column mode, which we use to typeset indexes.
@@ -3150,7 +3557,6 @@ width0pt\relax} \fi
   %
   % Double the \vsize as well.  (We don't need a separate register here,
   % since nobody clobbers \vsize.)
-  \advance\vsize by -\ht\partialpage
   \vsize = 2\vsize
 }
 
@@ -3164,6 +3570,7 @@ width0pt\relax} \fi
   % previous page.
   \dimen@ = \vsize
   \divide\dimen@ by 2
+  \advance\dimen@ by -\ht\partialpage
   %
   % box0 will be the left-hand column, box2 the right.
   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
@@ -3171,15 +3578,18 @@ width0pt\relax} \fi
   \unvbox255
   \penalty\outputpenalty
 }
+%
+% Re-output the contents of the output page -- any previous material,
+% followed by the two boxes we just split, in box0 and box2.
 \def\pagesofar{%
-  % Re-output the contents of the output page -- any previous material,
-  % followed by the two boxes we just split, in box0 and box2.
   \unvbox\partialpage
   %
   \hsize = \doublecolumnhsize
   \wd0=\hsize \wd2=\hsize
   \hbox to\pagewidth{\box0\hfil\box2}%
 }
+% 
+% All done with double columns.
 \def\enddoublecolumns{%
   \output = {%
     % Split the last of the double-column material.  Leave it on the
@@ -3204,8 +3614,9 @@ width0pt\relax} \fi
   % \endgroup where \vsize got restored).
   \pagegoal = \vsize
 }
+%
+% Called at the end of the double column material.
 \def\balancecolumns{%
-  % Called at the end of the double column material.
   \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
   \dimen@ = \ht0
   \advance\dimen@ by \topskip
@@ -3360,42 +3771,41 @@ width0pt\relax} \fi
 \outer\def\chapter{\parsearg\chapteryyy}
 \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
 \def\chapterzzz #1{%
-\secno=0 \subsecno=0 \subsubsecno=0
-\global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
-\chapmacro {#1}{\the\chapno}%
-\gdef\thissection{#1}%
-\gdef\thischaptername{#1}%
-% We don't substitute the actual chapter name into \thischapter
-% because we don't want its macros evaluated now.
-\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
-                                  {\the\chapno}}}%
-\temp
-\donoderef
-\global\let\section = \numberedsec
-\global\let\subsection = \numberedsubsec
-\global\let\subsubsection = \numberedsubsubsec
-}
+  \secno=0 \subsecno=0 \subsubsecno=0
+  \global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
+  \chapmacro {#1}{\the\chapno}%
+  \gdef\thissection{#1}%
+  \gdef\thischaptername{#1}%
+  % We don't substitute the actual chapter name into \thischapter
+  % because we don't want its macros evaluated now.
+  \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
+  \writetocentry{chap}{#1}{{\the\chapno}}
+  \donoderef
+  \global\let\section = \numberedsec
+  \global\let\subsection = \numberedsubsec
+  \global\let\subsubsection = \numberedsubsubsec
+}
+
+% we use \chapno to avoid indenting back
+\def\appendixbox#1{%
+  \setbox0 = \hbox{\putwordAppendix{} \the\chapno}%
+  \hbox to \wd0{#1\hss}}
 
 \outer\def\appendix{\parsearg\appendixyyy}
 \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
 \def\appendixzzz #1{%
-\secno=0 \subsecno=0 \subsubsecno=0
-\global\advance \appendixno by 1
-\message{\putwordAppendix\space \appendixletter}%
-\chapmacro {#1}{\putwordAppendix{} \appendixletter}%
-\gdef\thissection{#1}%
-\gdef\thischaptername{#1}%
-\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
-                       {\putwordAppendix{} \appendixletter}}}%
-\temp
-\appendixnoderef
-\global\let\section = \appendixsec
-\global\let\subsection = \appendixsubsec
-\global\let\subsubsection = \appendixsubsubsec
+  \secno=0 \subsecno=0 \subsubsecno=0
+  \global\advance \appendixno by 1
+  \message{\putwordAppendix\space \appendixletter}%
+  \chapmacro {#1}{\appendixbox{\putwordAppendix{} \appendixletter}}%
+  \gdef\thissection{#1}%
+  \gdef\thischaptername{#1}%
+  \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
+  \writetocentry{appendix}{#1}{{\appendixletter}}
+  \appendixnoderef
+  \global\let\section = \appendixsec
+  \global\let\subsection = \appendixsubsec
+  \global\let\subsubsection = \appendixsubsubsec
 }
 
 % @centerchap is like @unnumbered, but the heading is centered.
@@ -3408,149 +3818,121 @@ width0pt\relax} \fi
 \outer\def\unnumbered{\parsearg\unnumberedyyy}
 \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
 \def\unnumberedzzz #1{%
-\secno=0 \subsecno=0 \subsubsecno=0
-%
-% This used to be simply \message{#1}, but TeX fully expands the
-% argument to \message.  Therefore, if #1 contained @-commands, TeX
-% expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
-% expanded @cite (which turns out to cause errors because \cite is meant
-% to be executed, not expanded).
-%
-% Anyway, we don't want the fully-expanded definition of @cite to appear
-% as a result of the \message, we just want `@cite' itself.  We use
-% \the<toks register> to achieve this: TeX expands \the<toks> only once,
-% simply yielding the contents of <toks register>.  (We also do this for
-% the toc entries.)
-\toks0 = {#1}\message{(\the\toks0)}%
-%
-\unnumbchapmacro {#1}%
-\gdef\thischapter{#1}\gdef\thissection{#1}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}%
-\temp
-\unnumbnoderef
-\global\let\section = \unnumberedsec
-\global\let\subsection = \unnumberedsubsec
-\global\let\subsubsection = \unnumberedsubsubsec
+  \secno=0 \subsecno=0 \subsubsecno=0
+  %
+  % This used to be simply \message{#1}, but TeX fully expands the
+  % argument to \message.  Therefore, if #1 contained @-commands, TeX
+  % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
+  % expanded @cite (which turns out to cause errors because \cite is meant
+  % to be executed, not expanded).
+  %
+  % Anyway, we don't want the fully-expanded definition of @cite to appear
+  % as a result of the \message, we just want `@cite' itself.  We use
+  % \the<toks register> to achieve this: TeX expands \the<toks> only once,
+  % simply yielding the contents of <toks register>.  (We also do this for
+  % the toc entries.)
+  \toks0 = {#1}\message{(\the\toks0)}%
+  %
+  \unnumbchapmacro {#1}%
+  \gdef\thischapter{#1}\gdef\thissection{#1}%
+  \writetocentry{unnumbchap}{#1}{{\the\chapno}}
+  \unnumbnoderef
+  \global\let\section = \unnumberedsec
+  \global\let\subsection = \unnumberedsubsec
+  \global\let\subsubsection = \unnumberedsubsubsec
 }
 
 % Sections.
 \outer\def\numberedsec{\parsearg\secyyy}
 \def\secyyy #1{\numhead1{#1}} % normally calls seczzz
 \def\seczzz #1{%
-\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
-\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
-                                  {\the\chapno}{\the\secno}}}%
-\temp
-\donoderef
-\nobreak
+  \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
+  \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
+  \writetocentry{sec}{#1}{{\the\chapno}{\the\secno}}
+  \donoderef
+  \nobreak
 }
 
 \outer\def\appendixsection{\parsearg\appendixsecyyy}
 \outer\def\appendixsec{\parsearg\appendixsecyyy}
 \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
 \def\appendixsectionzzz #1{%
-\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
-\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
-                                  {\appendixletter}{\the\secno}}}%
-\temp
-\appendixnoderef
-\nobreak
+  \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
+  \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
+  \writetocentry{sec}{#1}{{\appendixletter}{\the\secno}}
+  \appendixnoderef
+  \nobreak
 }
 
 \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
 \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
 \def\unnumberedseczzz #1{%
-\plainsecheading {#1}\gdef\thissection{#1}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry{\the\toks0}}}%
-\temp
-\unnumbnoderef
-\nobreak
+  \plainsecheading {#1}\gdef\thissection{#1}%
+  \writetocentry{unnumbsec}{#1}{{\the\chapno}{\the\secno}}
+  \unnumbnoderef
+  \nobreak
 }
 
 % Subsections.
 \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
 \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
 \def\numberedsubseczzz #1{%
-\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
-\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
-                                    {\the\chapno}{\the\secno}{\the\subsecno}}}%
-\temp
-\donoderef
-\nobreak
+  \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
+  \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
+  \writetocentry{subsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}}
+  \donoderef
+  \nobreak
 }
 
 \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
 \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
 \def\appendixsubseczzz #1{%
-\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
-\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
-                                {\appendixletter}{\the\secno}{\the\subsecno}}}%
-\temp
-\appendixnoderef
-\nobreak
+  \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
+  \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
+  \writetocentry{subsec}{#1}{{\appendixletter}{\the\secno}{\the\subsecno}}
+  \appendixnoderef
+  \nobreak
 }
 
 \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
 \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
 \def\unnumberedsubseczzz #1{%
-\plainsubsecheading {#1}\gdef\thissection{#1}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry%
-                                    {\the\toks0}}}%
-\temp
-\unnumbnoderef
-\nobreak
+  \plainsubsecheading {#1}\gdef\thissection{#1}%
+  \writetocentry{unnumbsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}}
+  \unnumbnoderef
+  \nobreak
 }
 
 % Subsubsections.
 \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
 \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
 \def\numberedsubsubseczzz #1{%
-\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
-\subsubsecheading {#1}
-  {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
-  {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
-\temp
-\donoderef
-\nobreak
+  \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
+  \subsubsecheading {#1}
+    {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
+  \writetocentry{subsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}
+  \donoderef
+  \nobreak
 }
 
 \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
 \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
 \def\appendixsubsubseczzz #1{%
-\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
-\subsubsecheading {#1}
-  {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
-  {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
-\temp
-\appendixnoderef
-\nobreak
+  \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
+  \subsubsecheading {#1}
+    {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
+  \writetocentry{subsubsec}{#1}{{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}
+  \appendixnoderef
+  \nobreak
 }
 
 \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
 \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
 \def\unnumberedsubsubseczzz #1{%
-\plainsubsubsecheading {#1}\gdef\thissection{#1}%
-\toks0 = {#1}%
-\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry%
-                                    {\the\toks0}}}%
-\temp
-\unnumbnoderef
-\nobreak
+  \plainsubsubsecheading {#1}\gdef\thissection{#1}%
+  \writetocentry{unnumbsubsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}
+  \unnumbnoderef
+  \nobreak
 }
 
 % These are variants which are not "outer", so they can appear in @ifinfo.
@@ -3591,16 +3973,16 @@ width0pt\relax} \fi
 
 \def\majorheading{\parsearg\majorheadingzzz}
 \def\majorheadingzzz #1{%
-{\advance\chapheadingskip by 10pt \chapbreak }%
-{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
-                  \parindent=0pt\raggedright
-                  \rm #1\hfill}}\bigskip \par\penalty 200}
+  {\advance\chapheadingskip by 10pt \chapbreak }%
+  {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+                    \parindent=0pt\raggedright
+                    \rm #1\hfill}}\bigskip \par\penalty 200}
 
 \def\chapheading{\parsearg\chapheadingzzz}
 \def\chapheadingzzz #1{\chapbreak %
-{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
-                  \parindent=0pt\raggedright
-                  \rm #1\hfill}}\bigskip \par\penalty 200}
+  {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+                    \parindent=0pt\raggedright
+                    \rm #1\hfill}}\bigskip \par\penalty 200}
 
 % @heading, @subheading, @subsubheading.
 \def\heading{\parsearg\plainsecheading}
@@ -3746,7 +4128,16 @@ width0pt\relax} \fi
           \hangindent = \wd0 % zero if no section number
           \unhbox0 #3}%
   }%
-  \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak
+  % Add extra space after the heading -- either a line space or a
+  % paragraph space, whichever is more.  (Some people like to set
+  % \parskip to large values for some reason.)  Don't allow stretch, though.
+  \nobreak
+  \ifdim\parskip>\normalbaselineskip
+    \kern\parskip
+  \else
+    \kern\normalbaselineskip
+  \fi
+  \nobreak
 }
 
 
@@ -3758,16 +4149,30 @@ width0pt\relax} \fi
 % Called from @chapter, etc.  We supply {\folio} at the end of the
 % argument, which will end up as the last argument to the \...entry macro.
 %
-% We open the .toc file here instead of at @setfilename or any other
-% given time so that @contents can be put in the document anywhere.
+% Usage: \writetocentry{chap}{The Name of The Game}{{\the\chapno}}
+% We open the .toc file for writing here instead of at @setfilename (or
+% any other fixed time) so that @contents can be anywhere in the document.
 %
 \newif\iftocfileopened
-\def\writetocentry#1{%
+\def\writetocentry#1#2#3{%
   \iftocfileopened\else
     \immediate\openout\tocfile = \jobname.toc
     \global\tocfileopenedtrue
   \fi
-  \iflinks \write\tocfile{#1{\folio}}\fi
+  %
+  \iflinks
+    \toks0 = {#2}%
+    \edef\temp{\write\tocfile{\realbackslash #1entry{\the\toks0}#3{\folio}}}%
+    \temp
+  \fi
+  %
+  % Tell \shipout to create a page destination if we're doing pdf, which
+  % will be the target of the links in the table of contents.  We can't
+  % just do it on every page because the title pages are numbered 1 and
+  % 2 (the page numbers aren't printed), and so are the first two pages
+  % of the document.  Thus, we'd have two destinations named `1', and
+  % two named `2'.
+  \ifpdf \pdfmakepagedesttrue \fi
 }
 
 \newskip\contentsrightmargin \contentsrightmargin=1in
@@ -3798,7 +4203,7 @@ width0pt\relax} \fi
       \advance\hsize by -\contentsrightmargin % Don't use the full line length.
       %
       % Roman numerals for page numbers.
-      \ifnum \pageno>0 \pageno = \lastnegativepageno \fi
+      \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
 }
 
 
@@ -3815,7 +4220,7 @@ width0pt\relax} \fi
      \pdfmakeoutlines
    \endgroup
    \lastnegativepageno = \pageno
-   \pageno = \savepageno
+   \global\pageno = \savepageno
 }
 
 % And just the chapters.
@@ -3823,19 +4228,21 @@ width0pt\relax} \fi
    \startcontents{\putwordShortTOC}%
       %
       \let\chapentry = \shortchapentry
+      \let\appendixentry = \shortappendixentry
       \let\unnumbchapentry = \shortunnumberedentry
       % We want a true roman here for the page numbers.
       \secfonts
-      \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
+      \let\rm=\shortcontrm \let\bf=\shortcontbf
+      \let\sl=\shortcontsl \let\tt=\shortconttt
       \rm
       \hyphenpenalty = 10000
       \advance\baselineskip by 1pt % Open it up a little.
       \def\secentry ##1##2##3##4{}
-      \def\unnumbsecentry ##1##2{}
       \def\subsecentry ##1##2##3##4##5{}
-      \def\unnumbsubsecentry ##1##2{}
       \def\subsubsecentry ##1##2##3##4##5##6{}
-      \def\unnumbsubsubsecentry ##1##2{}
+      \let\unnumbsecentry = \secentry
+      \let\unnumbsubsecentry = \subsecentry
+      \let\unnumbsubsubsecentry = \subsubsecentry
       \openin 1 \jobname.toc
       \ifeof 1 \else
         \closein 1
@@ -3845,7 +4252,7 @@ width0pt\relax} \fi
      \contentsalignmacro % in case @setchapternewpage odd is in effect
    \endgroup
    \lastnegativepageno = \pageno
-   \pageno = \savepageno
+   \global\pageno = \savepageno
 }
 \let\shortcontents = \summarycontents
 
@@ -3858,16 +4265,24 @@ width0pt\relax} \fi
 % The last argument is the page number.
 % The arguments in between are the chapter number, section number, ...
 
-% Chapter-level things, for both the long and short contents.
+% Chapters, in the main contents.
 \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
-
-% See comments in \dochapentry re vbox and related settings
+%
+% Chapters, in the short toc.
+% See comments in \dochapentry re vbox and related settings.
 \def\shortchapentry#1#2#3{%
   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#3\egroup}%
 }
 
+% Appendices, in the main contents.
+\def\appendixentry#1#2#3{%
+  \dochapentry{\appendixbox{\putwordAppendix{} #2}\labelspace#1}{#3}}
+%
+% Appendices, in the short toc.
+\let\shortappendixentry = \shortchapentry
+
 % Typeset the label for a chapter or appendix for the short contents.
-% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
+% The arg is, e.g., `Appendix A' for an appendix, or `3' for a chapter.
 % We could simplify the code here by writing out an \appendixentry
 % command in the toc file for appendices, instead of using \chapentry
 % for both, but it doesn't seem worth it.
@@ -3875,38 +4290,31 @@ width0pt\relax} \fi
 \newdimen\shortappendixwidth
 %
 \def\shortchaplabel#1{%
-  % Compute width of word "Appendix", may change with language.
-  \setbox0 = \hbox{\shortcontrm \putwordAppendix}%
-  \shortappendixwidth = \wd0
-  %
-  % We typeset #1 in a box of constant width, regardless of the text of
-  % #1, so the chapter titles will come out aligned.
-  \setbox0 = \hbox{#1}%
-  \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
-  %
-  % This space should be plenty, since a single number is .5em, and the
+  % This space should be enough, since a single number is .5em, and the
   % widest letter (M) is 1em, at least in the Computer Modern fonts.
+  % But use \hss just in case.
   % (This space doesn't include the extra space that gets added after
   % the label; that gets put in by \shortchapentry above.)
-  \advance\dimen0 by 1.1em
-  \hbox to \dimen0{#1\hfil}%
+  \dimen0 = 1em
+  \hbox to \dimen0{#1\hss}%
 }
 
-\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
-\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno\bgroup#2\egroup}}
+% Unnumbered chapters.
+\def\unnumbchapentry#1#2#3{\dochapentry{#1}{#3}}
+\def\shortunnumberedentry#1#2#3{\tocentry{#1}{\doshortpageno\bgroup#3\egroup}}
 
 % Sections.
 \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
-\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
+\def\unnumbsecentry#1#2#3#4{\dosecentry{#1}{#4}}
 
 % Subsections.
 \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
-\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
+\def\unnumbsubsecentry#1#2#3#4#5{\dosubsecentry{#1}{#5}}
 
 % And subsubsections.
 \def\subsubsecentry#1#2#3#4#5#6{%
   \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
-\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
+\def\unnumbsubsubsecentry#1#2#3#4#5#6{\dosubsubsecentry{#1}{#6}}
 
 % This parameter controls the indentation of the various levels.
 \newdimen\tocindent \tocindent = 2.1pc %geuz 3pc
@@ -3917,7 +4325,7 @@ width0pt\relax} \fi
 % If the toc has to be broken over pages, we want it to be at chapters
 % if at all possible; hence the \penalty.
 \def\dochapentry#1#2{%
-   %geuz \penalty-300
+   %gmsh \penalty-300
    \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
    \begingroup
      \chapentryfonts
@@ -3948,7 +4356,7 @@ width0pt\relax} \fi
 \def\tocentry#1#2{\begingroup
   \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks
   % Do not use \turnoffactive in these arguments.  Since the toc is
-  % typeset in cmr, so characters such as _ would come out wrong; we
+  % typeset in cmr, characters such as _ would come out wrong; we
   % have to do the usual translation tricks.
   \entry{#1}{#2}%
 \endgroup}
@@ -3968,36 +4376,27 @@ width0pt\relax} \fi
 \message{environments,}
 % @foo ... @end foo.
 
+% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
+% 
 % Since these characters are used in examples, it should be an even number of
 % \tt widths. Each \tt character is 1en, so two makes it 1em.
-% Furthermore, these definitions must come after we define our fonts.
-\newbox\dblarrowbox    \newbox\longdblarrowbox
-\newbox\pushcharbox    \newbox\bullbox
-\newbox\equivbox       \newbox\errorbox
-
-%{\tentt
-%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
-%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
-%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
-%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
-% Adapted from the manmac format (p.420 of TeXbook)
-%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
-%                                      depth .1ex\hfil}
-%}
-
-% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
+%
 \def\point{$\star$}
 \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
 \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
 \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
 
+% The @error{} command.
 % Adapted from the TeXbook's \boxit.
+% 
+\newbox\errorbox
+%
 {\tentt \global\dimen0 = 3em}% Width of the box.
 \dimen2 = .55pt % Thickness of rules
 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
 \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
-
+%
 \global\setbox\errorbox=\hbox to \dimen0{\hfil
    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
    \advance\hsize by -2\dimen2 % Rules.
@@ -4008,8 +4407,7 @@ width0pt\relax} \fi
          \kern3pt\vrule width\dimen2}% Space to right.
       \hrule height\dimen2}
     \hfil}
-
-% The @error{} command.
+%
 \def\error{\leavevmode\lower.7ex\copy\errorbox}
 
 % @tex ... @end tex    escapes into raw Tex temporarily.
@@ -4019,14 +4417,14 @@ width0pt\relax} \fi
 \def\tex{\begingroup
   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
-  \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
+  \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
   \catcode `\%=14
-  \catcode 43=12 % plus
-  \catcode`\"=12
-  \catcode`\==12
-  \catcode`\|=12
-  \catcode`\<=12
-  \catcode`\>=12
+  \catcode `\+=\other
+  \catcode `\"=\other
+  \catcode `\==\other
+  \catcode `\|=\other
+  \catcode `\<=\other
+  \catcode `\>=\other
   \escapechar=`\\
   %
   \let\b=\ptexb
@@ -4041,6 +4439,7 @@ width0pt\relax} \fi
   \let\{=\ptexlbrace
   \let\+=\tabalign
   \let\}=\ptexrbrace
+  \let\/=\ptexslash
   \let\*=\ptexstar
   \let\t=\ptext
   %
@@ -4049,9 +4448,9 @@ width0pt\relax} \fi
   \def\@{@}%
 \let\Etex=\endgroup}
 
-% Define @lisp ... @endlisp.
+% Define @lisp ... @end lisp.
 % @lisp does a \begingroup so it can rebind things,
-% including the definition of @endlisp (which normally is erroneous).
+% including the definition of @end lisp (which normally is erroneous).
 
 % Amount to narrow the margins by for @lisp.
 \newskip\lispnarrowing \lispnarrowing=0.4in
@@ -4080,11 +4479,22 @@ width0pt\relax} \fi
 % Make spacing and below environment symmetrical.  We use \parskip here
 % to help in doing that, since in @example-like environments \parskip
 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
-% start of the next paragraph will insert \parskip
-%
-\def\aboveenvbreak{{\advance\envskipamount by \parskip
-\endgraf \ifdim\lastskip<\envskipamount
-\removelastskip \penalty-50 \vskip\envskipamount \fi}}
+% start of the next paragraph will insert \parskip.
+%
+\def\aboveenvbreak{{%
+  % =10000 instead of <10000 because of a special case in \itemzzz, q.v.
+  \ifnum \lastpenalty=10000 \else
+    \advance\envskipamount by \parskip
+    \endgraf
+    \ifdim\lastskip<\envskipamount
+      \removelastskip
+      % it's not a good place to break if the last penalty was \nobreak
+      % or better ...
+      \ifnum\lastpenalty>10000 \else \penalty-50 \fi
+      \vskip\envskipamount
+    \fi
+  \fi
+}}
 
 \let\afterenvbreak = \aboveenvbreak
 
@@ -4112,7 +4522,8 @@ width0pt\relax} \fi
 %
 \newskip\lskip\newskip\rskip
 
-\long\def\cartouche{%
+\def\cartouche{%
+\par  % can't be in the midst of a paragraph.
 \begingroup
         \lskip=\leftskip \rskip=\rightskip
         \leftskip=0pt\rightskip=0pt %we want these *outside*.
@@ -4159,7 +4570,6 @@ width0pt\relax} \fi
   \inENV % This group ends at the end of the body
   \hfuzz = 12pt % Don't be fussy
   \sepspaces % Make spaces be word-separators rather than space tokens.
-  \singlespace
   \let\par = \lisppar % don't ignore blank lines
   \obeylines % each line of input is a line of output
   \parskip = 0pt
@@ -4198,27 +4608,16 @@ width0pt\relax} \fi
 % @example: Same as @lisp.
 \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
 
-% @small... is usually equivalent to the non-small (@smallbook
-% redefines).  We must call \example (or whatever) last in the
-% definition, since it reads the return following the @example (or
-% whatever) command.
-%
-% This actually allows (for example) @end display inside an
-% @smalldisplay.  Too bad, but makeinfo will catch the error anyway.
-%
-\def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display}
-\def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp}
-\def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format}
-\def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
-
-% Real @smallexample and @smalllisp (when @smallbook): use smaller fonts.
+% @smallexample and @smalllisp: use smaller fonts.
 % Originally contributed by Pavel@xerox.
-\def\smalllispx{\begingroup
+\def\smalllisp{\begingroup
   \def\Esmalllisp{\nonfillfinish\endgroup}%
   \def\Esmallexample{\nonfillfinish\endgroup}%
-  \smallfonts
+  \smallexamplefonts
   \lisp
 }
+\let\smallexample = \smalllisp
+
 
 % @display: same as @lisp except keep current font.
 %
@@ -4227,12 +4626,12 @@ width0pt\relax} \fi
   \let\Edisplay = \nonfillfinish
   \gobble
 }
-
-% @smalldisplay (when @smallbook): @display plus smaller fonts.
 %
-\def\smalldisplayx{\begingroup
+% @smalldisplay: @display plus smaller fonts.
+%
+\def\smalldisplay{\begingroup
   \def\Esmalldisplay{\nonfillfinish\endgroup}%
-  \smallfonts \rm
+  \smallexamplefonts \rm
   \display
 }
 
@@ -4244,12 +4643,12 @@ width0pt\relax} \fi
   \let\Eformat = \nonfillfinish
   \gobble
 }
-
-% @smallformat (when @smallbook): @format plus smaller fonts.
 %
-\def\smallformatx{\begingroup
+% @smallformat: @format plus smaller fonts.
+%
+\def\smallformat{\begingroup
   \def\Esmallformat{\nonfillfinish\endgroup}%
-  \smallfonts \rm
+  \smallexamplefonts \rm
   \format
 }
 
@@ -4267,13 +4666,13 @@ width0pt\relax} \fi
   \gobble
 }
 
+
 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
 % and narrows the margins.
 %
 \def\quotation{%
   \begingroup\inENV %This group ends at the end of the @quotation body
   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
-  \singlespace
   \parindent=0pt
   % We have retained a nonzero parskip for the environment, since we're
   % doing normal filling. So to avoid extra space below the environment...
@@ -4289,23 +4688,257 @@ width0pt\relax} \fi
 }
 
 
+% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
+% If we want to allow any <char> as delimiter, 
+% we need the curly braces so that makeinfo sees the @verb command, eg:
+% `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
+%
+% [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
+%
+% [Knuth] p.344; only we need to do the other characters Texinfo sets
+% active too.  Otherwise, they get lost as the first character on a
+% verbatim line.
+\def\dospecials{%
+  \do\ \do\\\do\{\do\}\do\$\do\&%
+  \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
+  \do\<\do\>\do\|\do\@\do+\do\"%
+}
+%
+% [Knuth] p. 380
+\def\uncatcodespecials{%
+  \def\do##1{\catcode`##1=12}\dospecials}
+%
+% [Knuth] pp. 380,381,391
+% Disable Spanish ligatures ?` and !` of \tt font
+\begingroup
+  \catcode`\`=\active\gdef`{\relax\lq}
+\endgroup
+%
+% Setup for the @verb command.
+%
+% Eight spaces for a tab
+\begingroup
+  \catcode`\^^I=\active
+  \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
+\endgroup
+%
+\def\setupverb{%
+  \tt  % easiest (and conventionally used) font for verbatim
+  \def\par{\leavevmode\endgraf}%
+  \catcode`\`=\active
+  \tabeightspaces
+  % Respect line breaks,
+  % print special symbols as themselves, and
+  % make each space count
+  % must do in this order:
+  \obeylines \uncatcodespecials \sepspaces
+}
+
+% Setup for the @verbatim environment
+%
+% Real tab expansion
+\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
+%
+\def\starttabbox{\setbox0=\hbox\bgroup}
+\begingroup
+  \catcode`\^^I=\active
+  \gdef\tabexpand{%
+    \catcode`\^^I=\active
+    \def^^I{\leavevmode\egroup
+      \dimen0=\wd0 % the width so far, or since the previous tab
+      \divide\dimen0 by\tabw
+      \multiply\dimen0 by\tabw % compute previous multiple of \tabw
+      \advance\dimen0 by\tabw  % advance to next multiple of \tabw
+      \wd0=\dimen0 \box0 \starttabbox
+    }%
+  }
+\endgroup
+\def\setupverbatim{%
+  % Easiest (and conventionally used) font for verbatim
+  \tt
+  \def\par{\leavevmode\egroup\box0\endgraf}%
+  \catcode`\`=\active
+  \tabexpand
+  % Respect line breaks,
+  % print special symbols as themselves, and
+  % make each space count
+  % must do in this order:
+  \obeylines \uncatcodespecials \sepspaces
+  \everypar{\starttabbox}%
+}
+
+% Do the @verb magic: verbatim text is quoted by unique 
+% delimiter characters.  Before first delimiter expect a 
+% right brace, after last delimiter expect closing brace:
+%
+%    \def\doverb'{'<char>#1<char>'}'{#1}
+%
+% [Knuth] p. 382; only eat outer {}
+\begingroup
+  \catcode`[=1\catcode`]=2\catcode`\{=12\catcode`\}=12
+  \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
+\endgroup
+%
+\def\verb{\begingroup\setupverb\doverb}
+%
+%
+% Do the @verbatim magic: define the macro \doverbatim so that
+% the (first) argument ends when '@end verbatim' is reached, ie:
+%
+%     \def\doverbatim#1@end verbatim{#1}
+%
+% For Texinfo it's a lot easier than for LaTeX, 
+% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
+% we need not redefine '\', '{' and '}'.
+%
+% Inspired by LaTeX's verbatim command set [latex.ltx]
+%% Include LaTeX hack for completeness -- never know
+%% \begingroup
+%% \catcode`|=0 \catcode`[=1
+%% \catcode`]=2\catcode`\{=12\catcode`\}=12\catcode`\ =\active
+%% \catcode`\\=12|gdef|doverbatim#1@end verbatim[
+%% #1|endgroup|def|Everbatim[]|end[verbatim]]
+%% |endgroup
+%
+\begingroup
+  \catcode`\ =\active
+  \obeylines %
+  % ignore everything up to the first ^^M, that's the newline at the end
+  % of the @verbatim input line itself.  Otherwise we get an extra blank
+  % line in the output.
+  \gdef\doverbatim#1^^M#2@end verbatim{#2\end{verbatim}}%
+\endgroup
+%
+\def\verbatim{%
+  \def\Everbatim{\nonfillfinish\endgroup}%
+  \begingroup
+    \nonfillstart
+    \advance\leftskip by -\defbodyindent
+    \begingroup\setupverbatim\doverbatim
+}
+
+% @verbatiminclude FILE - insert text of file in verbatim environment.
+%
+% Allow normal characters that we make active in the argument (a file name).
+\def\verbatiminclude{%
+  \begingroup
+    \catcode`\\=\other
+    \catcode`~=\other
+    \catcode`^=\other
+    \catcode`_=\other
+    \catcode`|=\other
+    \catcode`<=\other
+    \catcode`>=\other
+    \catcode`+=\other
+    \parsearg\doverbatiminclude
+}
+\def\setupverbatiminclude{%
+  \begingroup
+    \nonfillstart
+    \advance\leftskip by -\defbodyindent
+    \begingroup\setupverbatim
+}
+%
+\def\doverbatiminclude#1{%
+     % Restore active chars for included file.
+  \endgroup
+  \begingroup
+    \let\value=\expandablevalue
+    \def\thisfile{#1}%
+    \expandafter\expandafter\setupverbatiminclude\input\thisfile
+  \endgroup
+  \nonfillfinish
+  \endgroup
+}
+
+% @copying ... @end copying.
+% Save the text away for @insertcopying later.  Many commands won't be
+% allowed in this context, but that's ok.
+% 
+% We save the uninterpreted tokens, rather than creating a box.
+% Saving the text in a box would be much easier, but then all the
+% typesetting commands (@smallbook, font changes, etc.) have to be done
+% beforehand -- and a) we want @copying to be done first in the source
+% file; b) letting users define the frontmatter in as flexible order as
+% possible is very desirable.
+% 
+\def\copying{\begingroup
+  % Define a command to swallow text until we reach `@end copying'.
+  % \ is the escape char in this texinfo.tex file, so it is the
+  % delimiter for the command; @ will be the escape char when we read
+  % it, but that doesn't matter.
+  \long\def\docopying##1\end copying{\gdef\copyingtext{##1}\enddocopying}%
+  %
+  % We must preserve ^^M's in the input file; see \insertcopying below.
+  \catcode`\^^M = \active
+  \docopying
+}
+
+% What we do to finish off the copying text.
+%
+\def\enddocopying{\endgroup\ignorespaces}
+
+% @insertcopying.  Here we must play games with ^^M's.  On the one hand,
+% we need them to delimit commands such as `@end quotation', so they
+% must be active.  On the other hand, we certainly don't want every
+% end-of-line to be a \par, as would happen with the normal active
+% definition of ^^M.  On the third hand, two ^^M's in a row should still
+% generate a \par.
+% 
+% Our approach is to make ^^M insert a space and a penalty1 normally;
+% then it can also check if \lastpenalty=1.  If it does, then manually
+% do \par.
+% 
+% This messes up the normal definitions of @c[omment], so we redefine
+% it.  Similarly for @ignore.  (These commands are used in the gcc
+% manual for man page generation.)
+% 
+% Seems pretty fragile, most line-oriented commands will presumably
+% fail, but for the limited use of getting the copying text (which
+% should be quite simple) inserted, we can hope it's ok.
+%
+{\catcode`\^^M=\active %
+\gdef\insertcopying{\begingroup %
+  \parindent = 0pt  % looks wrong on title page
+  \def^^M{%
+    \ifnum \lastpenalty=1 %
+      \par %
+    \else %
+      \space \penalty 1 %
+    \fi %
+  }%
+  %
+  % Fix @c[omment] for catcode 13 ^^M's.
+  \def\c##1^^M{\ignorespaces}%
+  \let\comment = \c %
+  %
+  % Don't bother jumping through all the hoops that \doignore does, it
+  % would be very hard since the catcodes are already set.
+  \long\def\ignore##1\end ignore{\ignorespaces}%
+  %
+  \copyingtext %
+\endgroup}%
+}
+
 \message{defuns,}
 % @defun etc.
 
 % Allow user to change definition object font (\df) internally
-\def\setdeffont #1 {\csname DEF#1\endcsname}
+\def\setdeffont#1 {\csname DEF#1\endcsname}
 
 \newskip\defbodyindent \defbodyindent=.4in
 \newskip\defargsindent \defargsindent=50pt
-\newskip\deftypemargin \deftypemargin=12pt
 \newskip\deflastargmargin \deflastargmargin=18pt
 
 \newcount\parencount
-% define \functionparens, which makes ( and ) and & do special things.
-% \functionparens affects the group it is contained in.
+
+% We want ()&[] to print specially on the defun line.
+% 
 \def\activeparens{%
-\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
-\catcode`\[=\active \catcode`\]=\active}
+  \catcode`\(=\active \catcode`\)=\active
+  \catcode`\&=\active
+  \catcode`\[=\active \catcode`\]=\active
+}
 
 % Make control sequences which act like normal parenthesis chars.
 \let\lparen = ( \let\rparen = )
@@ -4352,88 +4985,124 @@ width0pt\relax} \fi
 
 % Active &'s sneak into the index arguments, so make sure it's defined.
 {
-  \catcode`& = 13
+  \catcode`& = \active
   \global\let& = \ampnr
 }
 
-% First, defname, which formats the header line itself.
-% #1 should be the function name.
-% #2 should be the type of definition, such as "Function".
-
-\def\defname #1#2{%
-% Get the values of \leftskip and \rightskip as they were
-% outside the @def...
-\dimen2=\leftskip
-\advance\dimen2 by -\defbodyindent
-\noindent
-\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
-\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
-\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
-\parshape 2 0in \dimen0 \defargsindent \dimen1
-% Now output arg 2 ("Function" or some such)
-% ending at \deftypemargin from the right margin,
-% but stuck inside a box of width 0 so it does not interfere with linebreaking
-{% Adjust \hsize to exclude the ambient margins,
-% so that \rightline will obey them.
-\advance \hsize by -\dimen2
-\rlap{\rightline{{\rm #2}\hskip -1.25pc }}}%
-% Make all lines underfull and no complaints:
-\tolerance=10000 \hbadness=10000
-\advance\leftskip by -\defbodyindent
-\exdentamount=\defbodyindent
-{\df #1}\enskip        % Generate function name
-}
-
-% Actually process the body of a definition
-% #1 should be the terminating control sequence, such as \Edefun.
-% #2 should be the "another name" control sequence, such as \defunx.
-% #3 should be the control sequence that actually processes the header,
-%    such as \defunheader.
-
-\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
-\medbreak %
-% Define the end token that this defining construct specifies
-% so that it will exit this group.
-\def#1{\endgraf\endgroup\medbreak}%
-\def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
-\parindent=0in
-\advance\leftskip by \defbodyindent
-\exdentamount=\defbodyindent
-\begingroup %
-\catcode 61=\active % 61 is `='
-\obeylines\activeparens\spacesplit#3}
+% \defname, which formats the name of the @def (not the args).
+% #1 is the function name.
+% #2 is the type of definition, such as "Function".
+%
+\def\defname#1#2{%
+  % How we'll output the type name.  Putting it in brackets helps
+  % distinguish it from the body text that may end up on the next line
+  % just below it.
+  \ifempty{#2}%
+    \def\defnametype{}%
+  \else
+    \def\defnametype{[\rm #2]}%
+  \fi
+  %
+  % Get the values of \leftskip and \rightskip as they were outside the @def...
+  \dimen2=\leftskip
+  \advance\dimen2 by -\defbodyindent
+  %
+  % Figure out values for the paragraph shape.
+  \setbox0=\hbox{\hskip \deflastargmargin{\defnametype}}%
+  \dimen0=\hsize \advance \dimen0 by -\wd0  % compute size for first line
+  \dimen1=\hsize \advance \dimen1 by -\defargsindent  % size for continuations
+  \parshape 2 0in \dimen0 \defargsindent \dimen1
+  %
+  % Output arg 2 ("Function" or some such) but stuck inside a box of
+  % width 0 so it does not interfere with linebreaking.
+  \noindent
+  %
+  {% Adjust \hsize to exclude the ambient margins,
+   % so that \rightline will obey them.
+   \advance \hsize by -\dimen2
+   \dimen3 = 0pt  % was -1.25pc
+   \rlap{\rightline{\defnametype\kern\dimen3}}%
+  }%
+  %
+  % Allow all lines to be underfull without complaint:
+  \tolerance=10000 \hbadness=10000
+  \advance\leftskip by -\defbodyindent
+  \exdentamount=\defbodyindent
+  {\df #1}\enskip        % output function name
+  % \defunargs will be called next to output the arguments, if any.
+}
 
+% Common pieces to start any @def...
 % #1 is the \E... control sequence to end the definition (which we define).
-% #2 is the \...x control sequence for consecutive fns (which we define).
-% #3 is the control sequence to call to resume processing.
+% #2 is the \...x control sequence (which our caller defines).
+% #3 is the control sequence to process the header, such as \defunheader.
+% 
+\def\parsebodycommon#1#2#3{%
+  \begingroup\inENV
+  % If there are two @def commands in a row, we'll have a \nobreak,
+  % which is there to keep the function description together with its
+  % header.  But if there's nothing but headers, we want to allow a
+  % break after all.  Check for penalty 10002 (inserted by
+  % \defargscommonending) instead of 10000, since the sectioning
+  % commands insert a \penalty10000, and we don't want to allow a break
+  % between a section heading and a defun.
+  \ifnum\lastpenalty=10002 \penalty0 \fi
+  \medbreak
+  %
+  % Define the \E... end token that this defining construct specifies
+  % so that it will exit this group.
+  \def#1{\endgraf\endgroup\medbreak}%
+  %
+  \parindent=0in
+  \advance\leftskip by \defbodyindent
+  \exdentamount=\defbodyindent
+}
+
+% Common part of the \...x definitions.
+% 
+\def\defxbodycommon{%
+  % As with \parsebodycommon above, allow line break if we have multiple
+  % x headers in a row.  It's not a great place, though.
+  \ifnum\lastpenalty=10000 \penalty1000 \fi
+  %
+  \begingroup\obeylines
+}
+
+% Process body of @defun, @deffn, @defmac, etc.
+%
+\def\defparsebody#1#2#3{%
+  \parsebodycommon{#1}{#2}{#3}%
+  \def#2{\defxbodycommon \activeparens \spacesplit#3}%
+  \catcode\equalChar=\active
+  \begingroup\obeylines\activeparens
+  \spacesplit#3%
+}
+
+% #1, #2, #3 are the common arguments (see \parsebodycommon above).
 % #4, delimited by the space, is the class name.
 %
-\def\defmethparsebody#1#2#3#4 {\begingroup\inENV %
-\medbreak %
-% Define the end token that this defining construct specifies
-% so that it will exit this group.
-\def#1{\endgraf\endgroup\medbreak}%
-\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
-\parindent=0in
-\advance\leftskip by \defbodyindent
-\exdentamount=\defbodyindent
-\begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
+\def\defmethparsebody#1#2#3#4 {%
+  \parsebodycommon{#1}{#2}{#3}%
+  \def#2##1 {\defxbodycommon \activeparens \spacesplit{#3{##1}}}%
+  \begingroup\obeylines\activeparens
+  % The \empty here prevents misinterpretation of a construct such as
+  %   @deffn {whatever} {Enharmonic comma}
+  % See comments at \deftpparsebody, although in our case we don't have
+  % to remove the \empty afterwards, since it is empty.
+  \spacesplit{#3{#4}}\empty
+}
 
 % Used for @deftypemethod and @deftypeivar.
-% #1 is the \E... control sequence to end the definition (which we define).
-% #2 is the \...x control sequence for consecutive fns (which we define).
-% #3 is the control sequence to call to resume processing.
+% #1, #2, #3 are the common arguments (see \defparsebody).
 % #4, delimited by a space, is the class name.
 % #5 is the method's return type.
 %
-\def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV
-  \medbreak
-  \def#1{\endgraf\endgroup\medbreak}%
-  \def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}%
-  \parindent=0in
-  \advance\leftskip by \defbodyindent
-  \exdentamount=\defbodyindent
-  \begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}}
+\def\deftypemethparsebody#1#2#3#4 #5 {%
+  \parsebodycommon{#1}{#2}{#3}%
+  \def#2##1 ##2 {\defxbodycommon \activeparens \spacesplit{#3{##1}{##2}}}%
+  \begingroup\obeylines\activeparens
+  \spacesplit{#3{#4}{#5}}%
+}
 
 % Used for @deftypeop.  The change from \deftypemethparsebody is an
 % extra argument at the beginning which is the `category', instead of it
@@ -4442,64 +5111,48 @@ width0pt\relax} \fi
 % input at hand.  Thus also need a control sequence (passed as #5) for
 % the \E... definition to assign the category name to.
 % 
-\def\deftypeopparsebody#1#2#3#4#5 #6 {\begingroup\inENV
-  \medbreak
-  \def#1{\endgraf\endgroup\medbreak}%
-  \def#2##1 ##2 ##3 {%
-    \def#4{##1}%
-    \begingroup\obeylines\activeparens\spacesplit{#3{##2}{##3}}}%
-  \parindent=0in
-  \advance\leftskip by \defbodyindent
-  \exdentamount=\defbodyindent
-  \begingroup\obeylines\activeparens\spacesplit{#3{#5}{#6}}}
-
-\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
-\medbreak %
-% Define the end token that this defining construct specifies
-% so that it will exit this group.
-\def#1{\endgraf\endgroup\medbreak}%
-\def#2##1 ##2 {\def#4{##1}%
-\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
-\parindent=0in
-\advance\leftskip by \defbodyindent
-\exdentamount=\defbodyindent
-\begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
+\def\deftypeopparsebody#1#2#3#4#5 #6 {%
+  \parsebodycommon{#1}{#2}{#3}%
+  \def#2##1 ##2 ##3 {\def#4{##1}%
+    \defxbodycommon \activeparens \spacesplit{#3{##2}{##3}}}%
+  \begingroup\obeylines\activeparens
+  \spacesplit{#3{#5}{#6}}%
+}
+
+% For @defop.
+\def\defopparsebody #1#2#3#4#5 {%
+  \parsebodycommon{#1}{#2}{#3}%
+  \def#2##1 ##2 {\def#4{##1}%
+    \defxbodycommon \activeparens \spacesplit{#3{##2}}}%
+  \begingroup\obeylines\activeparens
+  \spacesplit{#3{#5}}%
+}
 
 % These parsing functions are similar to the preceding ones
 % except that they do not make parens into active characters.
 % These are used for "variables" since they have no arguments.
-
-\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
-\medbreak %
-% Define the end token that this defining construct specifies
-% so that it will exit this group.
-\def#1{\endgraf\endgroup\medbreak}%
-\def#2{\begingroup\obeylines\spacesplit#3}%
-\parindent=0in
-\advance\leftskip by \defbodyindent
-\exdentamount=\defbodyindent
-\begingroup %
-\catcode 61=\active %
-\obeylines\spacesplit#3}
-
-% This is used for \def{tp,vr}parsebody.  It could probably be used for
-% some of the others, too, with some judicious conditionals.
 %
-\def\parsebodycommon#1#2#3{%
-  \begingroup\inENV %
-  \medbreak %
-  % Define the end token that this defining construct specifies
-  % so that it will exit this group.
-  \def#1{\endgraf\endgroup\medbreak}%
-  \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
-  \parindent=0in
-  \advance\leftskip by \defbodyindent
-  \exdentamount=\defbodyindent
+\def\defvarparsebody #1#2#3{%
+  \parsebodycommon{#1}{#2}{#3}%
+  \def#2{\defxbodycommon \spacesplit#3}%
+  \catcode\equalChar=\active
+  \begingroup\obeylines
+  \spacesplit#3%
+}
+
+% @defopvar.
+\def\defopvarparsebody #1#2#3#4#5 {%
+  \parsebodycommon{#1}{#2}{#3}%
+  \def#2##1 ##2 {\def#4{##1}%
+    \defxbodycommon \spacesplit{#3{##2}}}%
   \begingroup\obeylines
+  \spacesplit{#3{#5}}%
 }
 
 \def\defvrparsebody#1#2#3#4 {%
   \parsebodycommon{#1}{#2}{#3}%
+  \def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}%
+  \begingroup\obeylines
   \spacesplit{#3{#4}}%
 }
 
@@ -4514,6 +5167,8 @@ width0pt\relax} \fi
 %
 \def\deftpparsebody #1#2#3#4 {%
   \parsebodycommon{#1}{#2}{#3}%
+  \def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}%
+  \begingroup\obeylines
   \spacesplit{\parsetpheaderline{#3{#4}}}\empty
 }
 
@@ -4530,38 +5185,37 @@ width0pt\relax} \fi
   #1{\removeemptybraces#2\relax}{#3}%
 }%
 
-\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
-\medbreak %
-% Define the end token that this defining construct specifies
-% so that it will exit this group.
-\def#1{\endgraf\endgroup\medbreak}%
-\def#2##1 ##2 {\def#4{##1}%
-\begingroup\obeylines\spacesplit{#3{##2}}}%
-\parindent=0in
-\advance\leftskip by \defbodyindent
-\exdentamount=\defbodyindent
-\begingroup\obeylines\spacesplit{#3{#5}}}
-
-% Split up #2 at the first space token.
+% Split up #2 (the rest of the input line) at the first space token.
 % call #1 with two arguments:
 %  the first is all of #2 before the space token,
 %  the second is all of #2 after that space token.
 % If #2 contains no space token, all of it is passed as the first arg
 % and the second is passed as empty.
-
-{\obeylines
-\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
-\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
-\ifx\relax #3%
-#1{#2}{}\else #1{#2}{#3#4}\fi}}
-
-% So much for the things common to all kinds of definitions.
+%
+{\obeylines %
+ \gdef\spacesplit#1#2^^M{\endgroup\spacesplitx{#1}#2 \relax\spacesplitx}%
+ \long\gdef\spacesplitx#1#2 #3#4\spacesplitx{%
+   \ifx\relax #3%
+     #1{#2}{}%
+   \else %
+     #1{#2}{#3#4}%
+   \fi}%
+}
 
 % Define @defun.
 
-% First, define the processing that is wanted for arguments of \defun
-% Use this to expand the args and terminate the paragraph they make up
+% This is called to end the arguments processing for all the @def... commands.
+%
+\def\defargscommonending{%
+  \interlinepenalty = 10000
+  \advance\rightskip by 0pt plus 1fil
+  \endgraf
+  \nobreak\vskip -\parskip
+  \penalty 10002  % signal to \parsebodycommon.
+}
 
+% This expands the args and terminates the paragraph they comprise.
+% 
 \def\defunargs#1{\functionparens \sl
 % Expand, preventing hyphenation at `-' chars.
 % Note that groups don't affect changes in \hyphenchar.
@@ -4570,9 +5224,7 @@ width0pt\relax} \fi
 #1%
 {\tensl\hyphenchar\font=45}%
 \ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
-\interlinepenalty=10000
-\advance\rightskip by 0pt plus 1fil
-\endgraf\nobreak\vskip -\parskip\nobreak
+  \defargscommonending
 }
 
 \def\deftypefunargs #1{%
@@ -4581,9 +5233,7 @@ width0pt\relax} \fi
 % Use \boldbraxnoamp, not \functionparens, so that & is not special.
 \boldbraxnoamp
 \tclose{#1}% avoid \code because of side effects on active chars
-\interlinepenalty=10000
-\advance\rightskip by 0pt plus 1fil
-\endgraf\nobreak\vskip -\parskip\nobreak
+  \defargscommonending
 }
 
 % Do complete processing of one @defun or @defunx line already parsed.
@@ -4594,7 +5244,7 @@ width0pt\relax} \fi
 
 \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
 \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
-\catcode 61=\other % Turn off change made in \defparsebody
+\catcode\equalChar=\other % Turn off change made in \defparsebody
 }
 
 % @defun == @deffn Function
@@ -4604,7 +5254,7 @@ width0pt\relax} \fi
 \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
 \begingroup\defname {#1}{\putwordDeffunc}%
 \defunargs {#2}\endgroup %
-\catcode 61=\other % Turn off change made in \defparsebody
+\catcode\equalChar=\other % Turn off change made in \defparsebody
 }
 
 % @deftypefun int foobar (int @var{foo}, float @var{bar})
@@ -4616,18 +5266,18 @@ width0pt\relax} \fi
 % #1 is the data type, #2 the name, #3 the args.
 \def\deftypefunheaderx #1#2 #3\relax{%
 \doind {fn}{\code{#2}}% Make entry in function index
-\begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypefun}%
+\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypefun}%
 \deftypefunargs {#3}\endgroup %
-\catcode 61=\other % Turn off change made in \defparsebody
+\catcode\equalChar=\other % Turn off change made in \defparsebody
 }
 
 % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
 
 \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
 
-% \defheaderxcond#1\relax$$$
+% \defheaderxcond#1\relax$.$
 % puts #1 in @code, followed by a space, but does nothing if #1 is null.
-\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi}
+\def\defheaderxcond#1#2$.${\ifx#1\relax\else\code{#1#2} \fi}
 
 % #1 is the classification.  #2 is the data type.  #3 is the name and args.
 \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
@@ -4637,9 +5287,9 @@ width0pt\relax} \fi
 \begingroup
 \normalparens % notably, turn off `&' magic, which prevents
 %               at least some C++ text from working
-\defname {\defheaderxcond#2\relax$$$#3}{#1}%
+\defname {\defheaderxcond#2\relax$.$#3}{#1}%
 \deftypefunargs {#4}\endgroup %
-\catcode 61=\other % Turn off change made in \defparsebody
+\catcode\equalChar=\other % Turn off change made in \defparsebody
 }
 
 % @defmac == @deffn Macro
@@ -4649,7 +5299,7 @@ width0pt\relax} \fi
 \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
 \begingroup\defname {#1}{\putwordDefmac}%
 \defunargs {#2}\endgroup %
-\catcode 61=\other % Turn off change made in \defparsebody
+\catcode\equalChar=\other % Turn off change made in \defparsebody
 }
 
 % @defspec == @deffn Special Form
@@ -4659,7 +5309,7 @@ width0pt\relax} \fi
 \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
 \begingroup\defname {#1}{\putwordDefspec}%
 \defunargs {#2}\endgroup %
-\catcode 61=\other % Turn off change made in \defparsebody
+\catcode\equalChar=\other % Turn off change made in \defparsebody
 }
 
 % @defop CATEGORY CLASS OPERATION ARG...
@@ -4668,9 +5318,11 @@ width0pt\relax} \fi
 \defopparsebody\Edefop\defopx\defopheader\defoptype}
 %
 \def\defopheader#1#2#3{%
-\dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index
-\begingroup\defname {#2}{\defoptype\ \putwordon\ #1}%
-\defunargs {#3}\endgroup %
+  \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% function index entry
+  \begingroup
+    \defname{#2}{\defoptype\ \putwordon\ #1}%
+    \defunargs{#3}%
+  \endgroup
 }
 
 % @deftypeop CATEGORY CLASS TYPE OPERATION ARG...
@@ -4683,7 +5335,7 @@ width0pt\relax} \fi
 \def\deftypeopheader#1#2#3#4{%
   \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
   \begingroup
-    \defname{\defheaderxcond#2\relax$$$#3}
+    \defname{\defheaderxcond#2\relax$.$#3}
             {\deftypeopcategory\ \putwordon\ \code{#1}}%
     \deftypefunargs{#4}%
   \endgroup
@@ -4698,7 +5350,7 @@ width0pt\relax} \fi
 \def\deftypemethodheader#1#2#3#4{%
   \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
   \begingroup
-    \defname{\defheaderxcond#2\relax$$$#3}{\putwordMethodon\ \code{#1}}%
+    \defname{\defheaderxcond#2\relax$.$#3}{\putwordMethodon\ \code{#1}}%
     \deftypefunargs{#4}%
   \endgroup
 }
@@ -4712,7 +5364,8 @@ width0pt\relax} \fi
 \def\deftypeivarheader#1#2#3{%
   \dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index
   \begingroup
-    \defname{#3}{\putwordInstanceVariableof\ \code{#1}}%
+    \defname{\defheaderxcond#2\relax$.$#3}
+            {\putwordInstanceVariableof\ \code{#1}}%
     \defvarargs{#3}%
   \endgroup
 }
@@ -4736,9 +5389,11 @@ width0pt\relax} \fi
 \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
 
 \def\defcvarheader #1#2#3{%
-\dosubind {vr}{\code{#2}}{\putwordof\ #1}% Make entry in var index
-\begingroup\defname {#2}{\defcvtype\ \putwordof\ #1}%
-\defvarargs {#3}\endgroup %
+  \dosubind{vr}{\code{#2}}{\putwordof\ \code{#1}}% variable index entry
+  \begingroup
+    \defname{#2}{\defcvtype\ \putwordof\ #1}%
+    \defvarargs{#3}%
+  \endgroup
 }
 
 % @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME
@@ -4746,7 +5401,7 @@ width0pt\relax} \fi
 \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
 %
 \def\defivarheader#1#2#3{%
-  \dosubind {vr}{\code{#2}}{\putwordof\ #1}% entry in var index
+  \dosubind{vr}{\code{#2}}{\putwordof\ \code{#1}}% entry in var index
   \begingroup
     \defname{#2}{\putwordInstanceVariableof\ #1}%
     \defvarargs{#3}%
@@ -4758,8 +5413,8 @@ width0pt\relax} \fi
 % This is actually simple: just print them in roman.
 % This must expand the args and terminate the paragraph they make up
 \def\defvarargs #1{\normalparens #1%
-\interlinepenalty=10000
-\endgraf\nobreak\vskip -\parskip\nobreak}
+  \defargscommonending
+}
 
 % @defvr Counter foo-count
 
@@ -4794,9 +5449,8 @@ width0pt\relax} \fi
 % is actually part of the data type, which should not be put into the index.
 \def\deftypevarheader #1#2{%
 \dovarind#2 \relax% Make entry in variables index
-\begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypevar}%
-\interlinepenalty=10000
-\endgraf\nobreak\vskip -\parskip\nobreak
+\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypevar}%
+  \defargscommonending
 \endgroup}
 \def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
 
@@ -4805,9 +5459,8 @@ width0pt\relax} \fi
 \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
 
 \def\deftypevrheader #1#2#3{\dovarind#3 \relax%
-\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1}
-\interlinepenalty=10000
-\endgraf\nobreak\vskip -\parskip\nobreak
+\begingroup\defname {\defheaderxcond#2\relax$.$#3}{#1}
+  \defargscommonending
 \endgroup}
 
 % Now define @deftp
@@ -4856,7 +5509,7 @@ width0pt\relax} \fi
  \def\scanmacro#1{%
    \begingroup \newlinechar`\^^M
    % Undo catcode changes of \startcontents and \doprintindex
-   \catcode`\@=0 \catcode`\\=12 \escapechar=`\@
+   \catcode`\@=0 \catcode`\\=\other \escapechar=`\@
    % Append \endinput to make sure that TeX does not see the ending newline.
    \toks0={#1\endinput}%
    \immediate\openout\macscribble=\jobname.tmp
@@ -4870,7 +5523,7 @@ width0pt\relax} \fi
 \def\scanmacro#1{%
 \begingroup \newlinechar`\^^M
 % Undo catcode changes of \startcontents and \doprintindex
-\catcode`\@=0 \catcode`\\=12 \escapechar=`\@
+\catcode`\@=0 \catcode`\\=\other \escapechar=`\@
 \let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup}
 \fi
 
@@ -4900,7 +5553,7 @@ width0pt\relax} \fi
 }
 
 % Trim a single trailing ^^M off a string.
-{\catcode`\^^M=12\catcode`\Q=3%
+{\catcode`\^^M=\other \catcode`\Q=3%
 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
 \gdef\eatcrb#1Q#2Q{#1}%
@@ -4915,29 +5568,29 @@ width0pt\relax} \fi
 % body, and then making it the \newlinechar in \scanmacro.
 
 \def\macrobodyctxt{%
-  \catcode`\~=12
-  \catcode`\^=12
-  \catcode`\_=12
-  \catcode`\|=12
-  \catcode`\<=12
-  \catcode`\>=12
-  \catcode`\+=12
-  \catcode`\{=12
-  \catcode`\}=12
-  \catcode`\@=12
-  \catcode`\^^M=12
+  \catcode`\~=\other
+  \catcode`\^=\other
+  \catcode`\_=\other
+  \catcode`\|=\other
+  \catcode`\<=\other
+  \catcode`\>=\other
+  \catcode`\+=\other
+  \catcode`\{=\other
+  \catcode`\}=\other
+  \catcode`\@=\other
+  \catcode`\^^M=\other
   \usembodybackslash}
 
 \def\macroargctxt{%
-  \catcode`\~=12
-  \catcode`\^=12
-  \catcode`\_=12
-  \catcode`\|=12
-  \catcode`\<=12
-  \catcode`\>=12
-  \catcode`\+=12
-  \catcode`\@=12
-  \catcode`\\=12}
+  \catcode`\~=\other
+  \catcode`\^=\other
+  \catcode`\_=\other
+  \catcode`\|=\other
+  \catcode`\<=\other
+  \catcode`\>=\other
+  \catcode`\+=\other
+  \catcode`\@=\other
+  \catcode`\\=\other}
 
 % \mbodybackslash is the definition of \ in @macro bodies.
 % It maps \foo\ => \csname macarg.foo\endcsname => #N
@@ -4965,7 +5618,7 @@ width0pt\relax} \fi
      \message{Warning: redefining \the\macname}%
   \else
      \expandafter\ifx\csname \the\macname\endcsname \relax
-     \else \errmessage{The name \the\macname\space is reserved}\fi
+     \else \errmessage{Macro name \the\macname\space already defined}\fi
      \global\cslet{macsave.\the\macname}{\the\macname}%
      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
      % Add the macroname to \macrolist
@@ -4978,32 +5631,33 @@ width0pt\relax} \fi
   \else \expandafter\parsemacbody
   \fi}
 
-\def\unmacro{\parsearg\unmacroxxx}
-\def\unmacroxxx#1{%
+\def\unmacro{\parsearg\dounmacro}
+\def\dounmacro#1{%
   \if1\csname ismacro.#1\endcsname
     \global\cslet{#1}{macsave.#1}%
     \global\expandafter\let \csname ismacro.#1\endcsname=0%
-    % Remove the macro name from \macrolist
+    % Remove the macro name from \macrolist:
     \begingroup
-      \edef\tempa{\expandafter\noexpand\csname#1\endcsname}%
-      \def\do##1{%
-        \def\tempb{##1}%
-        \ifx\tempa\tempb
-          % remove this
-        \else
-          \toks0 = \expandafter{\newmacrolist\do}%
-          \edef\newmacrolist{\the\toks0\expandafter\noexpand\tempa}%
-        \fi}%
-      \def\newmacrolist{}%
-      % Execute macro list to define \newmacrolist
-      \macrolist
-      \global\let\macrolist\newmacrolist
+      \expandafter\let\csname#1\endcsname \relax
+      \let\do\unmacrodo
+      \xdef\macrolist{\macrolist}%
     \endgroup
   \else
     \errmessage{Macro #1 not defined}%
   \fi
 }
 
+% Called by \do from \dounmacro on each macro.  The idea is to omit any
+% macro definitions that have been changed to \relax.
+% 
+\def\unmacrodo#1{%
+  \ifx#1\relax
+    % remove this
+  \else
+    \noexpand\do \noexpand #1%
+  \fi
+}
+
 % This makes use of the obscure feature that if the last token of a
 % <parameter list> is #, then the preceding argument is delimited by
 % an opening brace, and that opening brace is not consumed.
@@ -5151,8 +5805,8 @@ width0pt\relax} \fi
 
 % @node's job is to define \lastnode.
 \def\node{\ENVcheck\parsearg\nodezzz}
-\def\nodezzz#1{\nodexxx [#1,]}
-\def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
+\def\nodezzz#1{\nodexxx #1,\finishnodeparse}
+\def\nodexxx#1,#2\finishnodeparse{\gdef\lastnode{#1}}
 \let\nwnode=\node
 \let\lastnode=\relax
 
@@ -5186,15 +5840,23 @@ width0pt\relax} \fi
 \gdef\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
 \gdef\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
 
-% \setref{NAME}{SNT} defines a cross-reference point NAME, namely
-% NAME-title, NAME-pg, and NAME-SNT.  Called from \foonoderef.  We have
-% to set \indexdummies so commands such as @code in a section title
-% aren't expanded.  It would be nicer not to expand the titles in the
-% first place, but there's so many layers that that is hard to do.
+% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
+% anchor), namely NAME-title (the corresponding @chapter/etc. name),
+% NAME-pg (the page number), and NAME-snt (section number and type).
+% Called from \foonoderef.
+% 
+% We have to set \indexdummies so commands such as @code in a section
+% title aren't expanded.  It would be nicer not to expand the titles in
+% the first place, but there's so many layers that that is hard to do.
 %
+% Likewise, use \turnoffactive so that punctuation chars such as underscore
+% and backslash work in node names.
+% 
 \def\setref#1#2{{%
-  \indexdummies
+  \atdummies
   \pdfmkdest{#1}%
+  %
+  \turnoffactive
   \dosetq{#1-title}{Ytitle}%
   \dosetq{#1-pg}{Ypagenumber}%
   \dosetq{#1-snt}{#2}%
@@ -5246,13 +5908,15 @@ width0pt\relax} \fi
   \ifpdf
     \leavevmode
     \getfilename{#4}%
-    \ifnum\filenamelength>0
-      \startlink attr{/Border [0 0 0]}%
-        goto file{\the\filename.pdf} name{#1@}%
-    \else
-      \startlink attr{/Border [0 0 0]}%
-        goto name{#1@}%
-    \fi
+    {\turnoffactive \otherbackslash
+     \ifnum\filenamelength>0
+       \startlink attr{/Border [0 0 0]}%
+         goto file{\the\filename.pdf} name{#1}%
+     \else
+       \startlink attr{/Border [0 0 0]}%
+         goto name{#1}%
+     \fi
+    }%
     \linkcolor
   \fi
   %
@@ -5264,82 +5928,94 @@ width0pt\relax} \fi
     % into the usual \leavevmode...\vrule stuff for purposes of
     % printing. So we \turnoffactive for the \refx-snt, back on for the
     % printing, back off for the \refx-pg.
-    {\normalturnoffactive
+    {\turnoffactive \otherbackslash
      % Only output a following space if the -snt ref is nonempty; for
      % @unnumbered and @anchor, it won't be.
      \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
      \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
     }%
-    % [mynode],
-    [\printednodename],\space
-    % page 3
-    \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
+    % output the `[mynode]' via a macro.
+    \xrefprintnodename\printednodename
+    %
+    % But we always want a comma and a space:
+    ,\space
+    %
+    % output the `page 3'.
+    \turnoffactive \otherbackslash \putwordpage\tie\refx{#1-pg}{}%
   \fi
   \endlink
 \endgroup}
 
-% \dosetq is the interface for calls from other macros
+% This macro is called from \xrefX for the `[nodename]' part of xref
+% output.  It's a separate macro only so it can be changed more easily,
+% since not square brackets don't work in some documents.  Particularly
+% one that Bob is working on :).
+% 
+\def\xrefprintnodename#1{[#1]}
 
-% Use \normalturnoffactive so that punctuation chars such as underscore
-% and backslash work in node names.  (\turnoffactive doesn't do \.)
+% \dosetq is called from \setref to do the actual \write (\iflinks).
+%
 \def\dosetq#1#2{%
   {\let\folio=0%
-   \normalturnoffactive
    \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}%
-   \iflinks
-     \next
-   \fi
+   \iflinks \next \fi
   }%
 }
 
-% \internalsetq {foo}{page} expands into
-% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
-% When the aux file is read, ' is the escape character
-
-\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
-
-% Things to be expanded by \internalsetq
+% \internalsetq{foo}{page} expands into
+%   CHARACTERS @xrdef{foo}{...expansion of \page...}
+\def\internalsetq#1#2{@xrdef{#1}{\csname #2\endcsname}}
 
+% Things to be expanded by \internalsetq.
+% 
 \def\Ypagenumber{\folio}
-
 \def\Ytitle{\thissection}
-
 \def\Ynothing{}
-
 \def\Ysectionnumberandtype{%
-\ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
-\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
-\else \ifnum \subsubsecno=0 %
-\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
-\else %
-\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
-\fi \fi \fi }
+  \ifnum\secno=0
+    \putwordChapter@tie \the\chapno
+  \else \ifnum\subsecno=0
+    \putwordSection@tie \the\chapno.\the\secno
+  \else \ifnum\subsubsecno=0
+    \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
+  \else
+    \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
+  \fi\fi\fi
+}
 
 \def\Yappendixletterandtype{%
-\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
-\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
-\else \ifnum \subsubsecno=0 %
-\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
-\else %
-\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
-\fi \fi \fi }
-
-\gdef\xreftie{'tie}
+  \ifnum\secno=0
+     \putwordAppendix@tie @char\the\appendixno{}%
+  \else \ifnum\subsecno=0
+     \putwordSection@tie @char\the\appendixno.\the\secno
+  \else \ifnum\subsubsecno=0
+    \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
+  \else
+    \putwordSection@tie
+      @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
+  \fi\fi\fi
+}
 
 % Use TeX 3.0's \inputlineno to get the line number, for better error
 % messages, but if we're using an old version of TeX, don't do anything.
 %
 \ifx\inputlineno\thisisundefined
-  \let\linenumber = \empty % Non-3.0.
+  \let\linenumber = \empty % Pre-3.0.
 \else
   \def\linenumber{\the\inputlineno:\space}
 \fi
 
 % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
 % If its value is nonempty, SUFFIX is output afterward.
-
+%
 \def\refx#1#2{%
-  \expandafter\ifx\csname X#1\endcsname\relax
+  {%
+    \indexnofonts
+    \otherbackslash
+    \expandafter\global\expandafter\let\expandafter\thisrefX
+      \csname X#1\endcsname
+  }%
+  \ifx\thisrefX\relax
     % If not defined, say something at least.
     \angleleft un\-de\-fined\angleright
     \iflinks
@@ -5354,19 +6030,14 @@ width0pt\relax} \fi
     \fi
   \else
     % It's defined, so just use it.
-    \csname X#1\endcsname
+    \thisrefX
   \fi
   #2% Output the suffix in any case.
 }
 
 % This is the macro invoked by entries in the aux file.
 %
-\def\xrdef#1{\begingroup
-  % Reenable \ as an escape while reading the second argument.
-  \catcode`\\ = 0
-  \afterassignment\endgroup
-  \expandafter\gdef\csname X#1\endcsname
-}
+\def\xrdef#1{\expandafter\gdef\csname X#1\endcsname}
 
 % Read the last existing aux file, if any.  No error if none exists.
 \def\readauxfile{\begingroup
@@ -5397,9 +6068,7 @@ width0pt\relax} \fi
   \catcode`\^^]=\other
   \catcode`\^^^=\other
   \catcode`\^^_=\other
-  \catcode`\@=\other
-  \catcode`\^=\other
-  % It was suggested to define this as 7, which would allow ^^e4 etc.
+  % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
   % supported in the main text, it doesn't seem desirable.  Furthermore,
   % that is not enough: for node names that actually contain a ^
@@ -5412,6 +6081,9 @@ width0pt\relax} \fi
   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
   % and then to call \auxhat in \setq.
   %
+  \catcode`\^=\other
+  %
+  % Special characters.  Should be turned off anyway, but...
   \catcode`\~=\other
   \catcode`\[=\other
   \catcode`\]=\other
@@ -5423,7 +6095,9 @@ width0pt\relax} \fi
   \catcode`\$=\other
   \catcode`\#=\other
   \catcode`\&=\other
+  \catcode`\%=\other
   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
+  %
   % Make the characters 128-255 be printing characters
   {%
     \count 1=128
@@ -5433,17 +6107,18 @@ width0pt\relax} \fi
       \ifnum \count 1<256 \loop \fi
     }%
   }%
-  % The aux file uses ' as the escape (for now).
+  %
   % Turn off \ as an escape so we do not lose on
   % entries which were dumped with control sequences in their names.
-  % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
+  % For example, @xrdef{$\leq $-fun}{page ...} made by @defun ^^
   % Reference to such entries still does not work the way one would wish,
   % but at least they do not bomb out when the aux file is read in.
+  \catcode`\\=\other
+  %
+  % @ is our escape character in .aux files.
   \catcode`\{=1
   \catcode`\}=2
-  \catcode`\%=\other
-  \catcode`\'=0
-  \catcode`\\=\other
+  \catcode`\@=0
   %
   \openin 1 \jobname.aux
   \ifeof 1 \else
@@ -5488,7 +6163,7 @@ width0pt\relax} \fi
   % Remove inadvertent blank space before typesetting the footnote number.
   \unskip
   \thisfootno\@sf
-  \footnotezzz
+  \dofootnote
 }%
 
 % Don't bother with the trickery in plain.tex to not require the
@@ -5498,10 +6173,17 @@ width0pt\relax} \fi
 % \parseargline fail inside footnotes because the tokens are fixed when
 % the footnote is read.  --karl, 16nov96.
 %
-\long\gdef\footnotezzz{\insert\footins\bgroup
+% The start of the footnote looks usually like this:
+\gdef\startfootins{\insert\footins\bgroup}
+%
+% ... but this macro is redefined inside @multitable.
+%
+\gdef\dofootnote{%
+  \startfootins
   % We want to typeset this text as a normal paragraph, even if the
   % footnote reference occurs in (for example) a display environment.
   % So reset some parameters.
+  \hsize=\pagewidth
   \interlinepenalty\interfootnotelinepenalty
   \splittopskip\ht\strutbox % top baseline for broken footnotes
   \splitmaxdepth\dp\strutbox
@@ -5514,8 +6196,15 @@ width0pt\relax} \fi
   %
   \smallfonts \rm
   %
-  % Hang the footnote text off the number.
-  \hang
+  % Because we use hanging indentation in footnotes, a @noindent appears
+  % to exdent this text, so make it be a no-op.  makeinfo does not use
+  % hanging indentation so @noindent can still be needed within footnote
+  % text after an @example or the like (not that this is good style).
+  \let\noindent = \relax
+  %
+  % Hang the footnote text off the number.  Use \everypar in case the
+  % footnote extends for more than one paragraph.
+  \everypar = {\hang}%
   \textindent{\thisfootno}%
   %
   % Don't crash into the line above the footnote text.  Since this
@@ -5524,32 +6213,8 @@ width0pt\relax} \fi
   \footstrut
   \futurelet\next\fo@t
 }
-\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
-  \else\let\next\f@t\fi \next}
-\def\f@@t{\bgroup\aftergroup\@foot\let\next}
-\def\f@t#1{#1\@foot}
-\def\@foot{\strut\par\egroup}
-
 }%end \catcode `\@=11
 
-% Set the baselineskip to #1, and the lineskip and strut size
-% correspondingly.  There is no deep meaning behind these magic numbers
-% used as factors; they just match (closely enough) what Knuth defined.
-%
-\def\lineskipfactor{.08333}
-\def\strutheightpercent{.70833}
-\def\strutdepthpercent {.29167}
-%
-\def\setleading#1{%
-  \normalbaselineskip = #1\relax
-  \normallineskip = \lineskipfactor\normalbaselineskip
-  \normalbaselines
-  \setbox\strutbox =\hbox{%
-    \vrule width0pt height\strutheightpercent\baselineskip
-                    depth \strutdepthpercent \baselineskip
-  }%
-}
-
 % @| inserts a changebar to the left of the current line.  It should
 % surround any changed text.  This approach does *not* work if the
 % change spans more than two lines of output.  To handle that, we would
@@ -5594,8 +6259,8 @@ width0pt\relax} \fi
 \openin 1 = epsf.tex
 \ifeof 1 \else
   \closein 1
-  % Do not bother showing banner with post-v2.7 epsf.tex (available in
-  % doc/epsf.tex until it shows up on ctan).
+  % Do not bother showing banner with epsf.tex v2.7k (available in
+  % doc/epsf.tex and on ctan).
   \def\epsfannounce{\toks0 = }%
   \input epsf.tex
 \fi
@@ -5614,40 +6279,44 @@ width0pt\relax} \fi
       \global\warnednoepsftrue
     \fi
   \else
-    \imagexxx #1,,,\finish
+    \imagexxx #1,,,,,\finish
   \fi
 }
 %
 % Arguments to @image:
 % #1 is (mandatory) image filename; we tack on .eps extension.
 % #2 is (optional) width, #3 is (optional) height.
-% #4 is just the usual extra ignored arg for parsing this stuff.
-\def\imagexxx#1,#2,#3,#4\finish{%
+% #4 is (ignored optional) html alt text.
+% #5 is (ignored optional) extension.
+% #6 is just the usual extra ignored arg for parsing this stuff.
+\newif\ifimagevmode
+\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
+  \catcode`\^^M = 5     % in case we're inside an example
+  \normalturnoffactive  % allow _ et al. in names
+  % If the image is by itself, center it.
+  \ifvmode
+    \imagevmodetrue
+    \nobreak\bigskip
+    % Usually we'll have text after the image which will insert
+    % \parskip glue, so insert it here too to equalize the space
+    % above and below. 
+    \nobreak\vskip\parskip
+    \nobreak
+    \line\bgroup\hss
+  \fi
+  %
+  % Output the image.
   \ifpdf
-    \centerline{\dopdfimage{#1}{#2}{#3}}%
+    \dopdfimage{#1}{#2}{#3}%
   \else
     % \epsfbox itself resets \epsf?size at each figure.
     \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
     \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
-    \begingroup
-      \catcode`\^^M = 5 % in case we're inside an example
-      % If the image is by itself, center it.
-      \ifvmode
-        \nobreak\bigskip
-        % Usually we'll have text after the image which will insert
-        % \parskip glue, so insert it here too to equalize the space
-        % above and below. 
-        \nobreak\vskip\parskip
-        \nobreak
-        \centerline{\epsfbox{#1.eps}}%
-        \bigbreak
-      \else
-        % In the middle of a paragraph, no extra space.
-        \epsfbox{#1.eps}%
-      \fi
-    \endgroup
+    \epsfbox{#1.eps}%
   \fi
-}
+  %
+  \ifimagevmode \hss \egroup \bigbreak \fi  % space after the image
+\endgroup}
 
 
 \message{localization,}
@@ -5716,10 +6385,13 @@ should work if nowhere else does.}
 }
 
 % Parameters in order: 1) textheight; 2) textwidth; 3) voffset;
-% 4) hoffset; 5) binding offset; 6) topskip.  Then whoever calls us can
-% set \parskip and call \setleading for \baselineskip.
+% 4) hoffset; 5) binding offset; 6) topskip; 7) physical page height; 8)
+% physical page width.
+% 
+% We also call \setleading{\textleading}, so the caller should define
+% \textleading.  The caller should also set \parskip.
 %
-\def\internalpagesizes#1#2#3#4#5#6{%
+\def\internalpagesizes#1#2#3#4#5#6#7#8{%
   \voffset = #3\relax
   \topskip = #6\relax
   \splittopskip = \topskip
@@ -5738,6 +6410,13 @@ should work if nowhere else does.}
   \normaloffset = #4\relax
   \bindingoffset = #5\relax
   %
+  \ifpdf
+    \pdfpageheight #7\relax
+    \pdfpagewidth #8\relax
+  \fi
+  %
+  \setleading{\textleading}
+  %
   \parindent = \defaultparindent
   \setemergencystretch
 }
@@ -5745,61 +6424,99 @@ should work if nowhere else does.}
 % @letterpaper (the default).
 \def\letterpaper{{\globaldefs = 1
   \parskip = 3pt plus 2pt minus 1pt
-  \setleading{13.2pt}%
+  \textleading = 13.2pt
   %
   % If page is nothing but text, make it come out even.
-  \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}%
+  \internalpagesizes{46\baselineskip}{6in}%
+                    {\voffset}{.25in}%
+                    {\bindingoffset}{36pt}%
+                    {11in}{8.5in}%
 }}
 
 % Use @smallbook to reset parameters for 7x9.5 (or so) format.
 \def\smallbook{{\globaldefs = 1
   \parskip = 2pt plus 1pt
-  \setleading{12pt}%
+  \textleading = 12pt
   %
-  \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}%
+  \internalpagesizes{7.5in}{5in}%
+                    {\voffset}{.25in}%
+                    {\bindingoffset}{16pt}%
+                    {9.25in}{7in}%
   %
   \lispnarrowing = 0.3in
   \tolerance = 700
   \hfuzz = 1pt
   \contentsrightmargin = 0pt
-  \deftypemargin = 0pt
   \defbodyindent = .5cm
-  %
-  \let\smalldisplay = \smalldisplayx
-  \let\smallexample = \smalllispx
-  \let\smallformat = \smallformatx
-  \let\smalllisp = \smalllispx
 }}
 
 % Use @afourpaper to print on European A4 paper.
 \def\afourpaper{{\globaldefs = 1
-  \setleading{12pt}%
   \parskip = 3pt plus 2pt minus 1pt
+  \textleading = 13.2pt
   %
-  \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}%
+  % Double-side printing via postscript on Laserjet 4050 
+  % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
+  % To change the settings for a different printer or situation, adjust
+  % \normaloffset until the front-side and back-side texts align.  Then
+  % do the same for \bindingoffset.  You can set these for testing in
+  % your texinfo source file like this:
+  % @tex
+  % \global\normaloffset = -6mm
+  % \global\bindingoffset = 10mm
+  % @end tex
+  \internalpagesizes{51\baselineskip}{160mm}
+                    {\voffset}{\hoffset}%
+                    {\bindingoffset}{44pt}%
+                    {297mm}{210mm}%
   %
   \tolerance = 700
   \hfuzz = 1pt
+  \contentsrightmargin = 0pt
+  \defbodyindent = 5mm
 }}
 
-% A specific text layout, 24x15cm overall, intended for A4 paper.  Top margin
-% 29mm, hence bottom margin 28mm, nominal side margin 3cm.
-\def\afourlatex{{\globaldefs = 1
-  \setleading{13.6pt}%
+% Use @afivepaper to print on European A5 paper.
+% From romildo@urano.iceb.ufop.br, 2 July 2000.
+% He also recommends making @example and @lisp be small.
+\def\afivepaper{{\globaldefs = 1
+  \parskip = 2pt plus 1pt minus 0.1pt
+  \textleading = 12.5pt
+  %
+  \internalpagesizes{160mm}{120mm}%
+                    {\voffset}{\hoffset}%
+                    {\bindingoffset}{8pt}%
+                    {210mm}{148mm}%
   %
+  \lispnarrowing = 0.2in
+  \tolerance = 800
+  \hfuzz = 1.2pt
+  \contentsrightmargin = 0pt
+  \defbodyindent = 2mm
+  \tableindent = 12mm
+}}
+
+% A specific text layout, 24x15cm overall, intended for A4 paper.  
+\def\afourlatex{{\globaldefs = 1
   \afourpaper
-  \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}%
+  \internalpagesizes{237mm}{150mm}%
+                    {\voffset}{4.6mm}%
+                    {\bindingoffset}{7mm}%
+                    {297mm}{210mm}%
   %
+  % Must explicitly reset to 0 because we call \afourpaper.
   \globaldefs = 0
 }}
 
-% Use @afourwide to print on European A4 paper in wide format.
-\def\afourwide{%
+% Use @afourwide to print on A4 paper in landscape format.
+\def\afourwide{{\globaldefs = 1
   \afourpaper
-  \internalpagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}%
-  %
+  \internalpagesizes{241mm}{165mm}%
+                    {\voffset}{-2.95mm}%
+                    {\bindingoffset}{7mm}%
+                    {297mm}{210mm}%
   \globaldefs = 0
-}
+}}
 
 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
 % Perhaps we should allow setting the margins, \topskip, \parskip,
@@ -5812,9 +6529,18 @@ should work if nowhere else does.}
   \globaldefs = 1
   %
   \parskip = 3pt plus 2pt minus 1pt
-  \setleading{13.2pt}%
+  \setleading{\textleading}%
   %
-  \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}%
+  \dimen0 = #1
+  \advance\dimen0 by \voffset
+  %
+  \dimen2 = \hsize
+  \advance\dimen2 by \normaloffset
+  %
+  \internalpagesizes{#1}{\hsize}%
+                    {\voffset}{\normaloffset}%
+                    {\bindingoffset}{44pt}%
+                    {\dimen0}{\dimen2}%
 }}
 
 % Set default to letter.
@@ -5842,7 +6568,7 @@ should work if nowhere else does.}
 \def\normalless{<}
 \def\normalgreater{>}
 \def\normalplus{+}
-\def\normaldollar{$}
+\def\normaldollar{$}%$ font-lock fix
 
 % This macro is used to make a character print one way in ttfont
 % where it can probably just be output, and another way in other fonts,
@@ -5878,7 +6604,7 @@ should work if nowhere else does.}
 \catcode`\_=\active
 \def_{\ifusingtt\normalunderscore\_}
 % Subroutine for the previous macro.
-\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}}
+\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
 
 \catcode`\|=\active
 \def|{{\tt\char124}}
@@ -5891,9 +6617,7 @@ should work if nowhere else does.}
 \catcode`\+=\active
 \def+{{\tt \char 43}}
 \catcode`\$=\active
-\def${\ifusingit{{\sl\$}}\normaldollar}
-%\catcode 27=\active
-%\def^^[{$\diamondsuit$}
+\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
 
 % Set up an active definition for =, but don't enable it most of the time.
 {\catcode`\==\active
@@ -5910,44 +6634,46 @@ should work if nowhere else does.}
 
 \catcode`\@=0
 
-% \rawbackslashxx output one backslash character in current font
+% \rawbackslashxx outputs one backslash character in current font,
+% as in \char`\\.
 \global\chardef\rawbackslashxx=`\\
-%{\catcode`\\=\other
-%@gdef@rawbackslashxx{\}}
 
-% \rawbackslash redefines \ as input to do \rawbackslashxx.
+% \rawbackslash defines an active \ to do \rawbackslashxx.
+% \otherbackslash defines an active \ to be a literal `\' character with
+% catcode other.
 {\catcode`\\=\active
-@gdef@rawbackslash{@let\=@rawbackslashxx }}
+ @gdef@rawbackslash{@let\=@rawbackslashxx}
+ @gdef@otherbackslash{@let\=@realbackslash}
+}
+
+% \realbackslash is an actual character `\' with catcode other.
+{\catcode`\\=\other @gdef@realbackslash{\}}
 
 % \normalbackslash outputs one backslash in fixed width font.
 \def\normalbackslash{{\tt\rawbackslashxx}}
 
-% \catcode 17=0   % Define control-q
 \catcode`\\=\active
 
 % Used sometimes to turn off (effectively) the active characters
 % even after parsing them.
-@def@turnoffactive{@let"=@normaldoublequote
-@let\=@realbackslash
-@let~=@normaltilde
-@let^=@normalcaret
-@let_=@normalunderscore
-@let|=@normalverticalbar
-@let<=@normalless
-@let>=@normalgreater
-@let+=@normalplus
-@let$=@normaldollar}
-
-@def@normalturnoffactive{@let"=@normaldoublequote
-@let\=@normalbackslash
-@let~=@normaltilde
-@let^=@normalcaret
-@let_=@normalunderscore
-@let|=@normalverticalbar
-@let<=@normalless
-@let>=@normalgreater
-@let+=@normalplus
-@let$=@normaldollar}
+@def@turnoffactive{%
+  @let"=@normaldoublequote
+  @let\=@realbackslash
+  @let~=@normaltilde
+  @let^=@normalcaret
+  @let_=@normalunderscore
+  @let|=@normalverticalbar
+  @let<=@normalless
+  @let>=@normalgreater
+  @let+=@normalplus
+  @let$=@normaldollar %$ font-lock fix
+}
+
+% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
+% the literal character `\'.  (Thus, \ is not expandable when this is in
+% effect.)
+% 
+@def@normalturnoffactive{@turnoffactive @let\=@normalbackslash}
 
 % Make _ and + \other characters, temporarily.
 % This is canceled by @fixbackslash.