%% MIRIAM;  PLEASE CALL THIS  labelfig tex



  %%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%
 %%%%%   LABELFIG.TEX FOR LABELLING FIGURE INSERTS %%%%%
  %%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%
 %%%  AUTHORS: Raymond S\'eroul and Laurent Siebenmann
  %%    A18645@FRCCSC21.bitnet and lcs@topo.math.u-psud.fr
  %%
 %%%  VERSIONS: July 1991 --- Jan 1993
  %%
 %%%  PURPOSE:
  %%  Occasionally, figures imported into TeX lack some labels.
  %%  It may then be most appropriate to use TeX to provide
  %%  the labels.  Several macro sets, notably the 
  %%  LaTeX picture environment, provide means to insert 
  %%  labels.  labelfig.tex is a macro set offering 
  %%  labelling capability for other TeX formats such
  %%  as Plain and AmSTeX. Unlike most graphics tools it is 
  %%  fast and of moderate size (costing about 1 Ko of main 
  %%  memory and 60 control sequences). Hopefully it will work 
  %%  in essentially all TeX environments.
  %%
 %%%  THE IDEA:
  %%  A grid is laid down on the figure, as in the LaTeX
  %%  picture environment, and the labels are then
  %%  located with respect to the grid.
  %%  There are two auxiliary devices that give this 
  %%  macro package a touch of novelty even for LateX users.
  %%  (a)  the grid appears on the preview/preprint.
  %%  For users with a fast preview this makes 
  %%  labeling an interactive process.
  %%  (b)  the grid is canonical, i.e. so naturally chosen
  %%  that labels will probably remain well placed
  %%  if the figure scale is changed.
  %% 
 %%%  MAIN POSTINGS : anonymous ftp
  %%  ---  ftp ftp.math.u-psud.fr
  %%  login: anonymous; password: <anything>; directory
  %%  TeX/Graphics.dir.  This is the master posting in 1993.
  %%  ---  CTAN archives
  %% 
 %%%% DOCUMENTATION:
  %%  --- see labelfig.doc 
  %% (may be included at end, after \endinput)
  %%
 %%%% EXAMPLE OF USAGE:
  %%    \input labelfig.tex
  %%    \SetLabels
  %%      (.3*.7) first label\\
  %%         % center of baseline of the label
  %%         % will go to position .3 from left 
  %%         % and .7 from bottom
  %%      \L(.61*.333) $\Lambda_1\leq\Gamma$\\
  %%         % \L places left edge of label 
  %%         % (rather than the center)
  %%         % similarly use \R for right edge;
  %%         % and \B for bottom, \E for equator, and \T for top
  %%      \T\R(.3*.7) last label \\
  %%    \endSetLabels
  %%    \ShowGrid
  %%         % lays grid on figure to label; 
  %%         % delete for final printing
  %%    \AffixLabels{\BoxedEPSF{MyFigure}}
  %%         % argument of \AffixLabels#1 should be a TeX box;
  %%         % the grid will cover exactly that box.
  %%         % (Here \BoxedEPSF is the figure insertion macro
  %%         % of the package boxedeps.tex (same sources) 
  %%         % for inserting encapsulated PostScript graphics. 
  %%         % But any other means of inserting 
  %%         % the figure can be used.)
  %%         


 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 %%%%% FORBID REREADING %%%%%
  %
  \ifx\LabelFigloaded\MYundefined\relax
  \else
    \message{ !!! labelfig.tex ALREADY loaded !!!}
  \endinput\fi

  \def\LabelFigloaded{\relax}% now loaded

  %%% Beyond this point we use some control sequences
  %%% that are 'padlocked'  with @ of category 11

  \chardef\LabelFigCatAt\the\catcode`\@
  \catcode`\@=11

 %%temporarily suppress Plain's logging of allocations
 \let\LabelFigwlog@ld\wlog
 \def\wlog#1{\relax}

 \ifx\\\MYundefined@
    \let\\\relax
 \fi

 %%%%%%% end of preamble

  \def\ms@g{\immediate\write16}

 \def\N@wif{\csname newif\endcsname }
 \def\Temp@ {\N@wif\ifIN@}
 \ifx\INN@\MYundefined@
    \else \let\Temp@\relax
 \fi
 \Temp@

  %%% \IN@0#1@#2@ : Is 1st exp of #1 in 1st exp of #2 ??
   %% Answer in \ifIN@
  %\newif\ifIN@ %% conserve if's
  \def\IN@{\expandafter\INN@\expandafter}
  \long\def\INN@0#1@#2@{\long\def\NI@##1#1##2##3\ENDNI@
    {\ifx\m@rker##2\IN@false\else\IN@true\fi}%
     \expandafter\NI@#2@@#1\m@rker\ENDNI@}
  \def\m@rker{\m@@rker}
 
  %%%  \SPLIT@0#1@#2@  :  Split 1st exp of #2 at 1st exp of #1
   %%  \Initialtoks@ , \Terminaltoks@ will contain pieces
  \newtoks\Initialtoks@  \newtoks\Terminaltoks@
  \def\SPLIT@{\expandafter\SPLITT@\expandafter}
  \def\SPLITT@0#1@#2@{\def\TTILPS@##1#1##2@{%
     \Initialtoks@{##1}\Terminaltoks@{##2}}\expandafter\TTILPS@#2@}

   %%% \Shifted@@#1#2#3 puts #3 in \hbox
   %% leaves basepoint as is
   %% then translates ink only by dims #1,#2
   %% with Postscript convention
   %% For simplicity use only on scrunched boxes
 \def\Shifted@@#1#2#3{\setbox0=\hbox{#3}%
   \raise -\dp0\vbox {\kern-#2%
       \hbox {\kern#1\unhbox0\kern-#1}%
           \kern#2}}

 \newcount\gridcount
 \newbox\auxGridbox@ \newbox\hGridbox@ \newbox\vGridbox@
 \newbox\Labelbox@ \newbox\auxLabelbox@
 \newbox\Coordinatebox@
 \newtoks\Labeltoks@
 \newdimen\Wdd@ \newdimen\Htt@
 \newdimen\Wddd@ \newdimen\Httt@
 
 \def\Wr@{\immediate\write16}

 \newdimen\GL@wd%% grid-line width
 \GL@wd=.02pt
 \def\GridLineWidth#1{\GL@wd=#1}

 \def\gobble#1{}
 \def\EdgeErr@{\Wr@{}%
      \Wr@{\string\Edges\space argument
      1, 10, 100 or 1000 please\string!}%
      }

 \newcount\Edgect@

 \def\Sweepup#1\endSweepup{}

 \def\SetEdges@{%
    \edef\Zr@@s{\expandafter\gobble\number\Edgect@\empty}%
        %% Now check \Zr@@s is zeros
        \count255=0\Zr@@s\relax
        \ifnum\count255=\z@\else\EdgeErr@\show\tailtest\fi
        %% Now check first digit
        \count255=1\Zr@@s\relax%\showthe\count255
        \ifnum\count255=\Edgect@\relax\else\EdgeErr@\show\leadtest\fi
    \EdgGl@b\edef\Zr@s{\expandafter\gobble\Zr@@s\empty}%\show\Zr@s
    \ifnum\Edgect@>\@ne\relax\EdgGl@b\let\L@Dc\empty
        \else\EdgGl@b\edef\L@Dc{\string.}\fi
    \ifnum\Edgect@>\@ne\relax
        \EdgGl@b\edef\Edgescale@##1{\divide##1 by \Edgect@}%
        \else\EdgGl@b\edef\Edgescale@##1{}\fi
    }

 \def\Edges#1{\Edgect@=#1\relax
     \let\EdgGl@b\global \SetEdges@}

 \Edges{1}%% default

 \def\hhrule{\hrule height \GL@wd\vskip-.\GL@wd}

 \def\hRule@{%
   \advance\gridcount -2%
   \vfil\hhrule\vfil
   \llap{\smash{\raise -2.5pt
     \hbox{\L@Dc\number\gridcount\Zr@s\kern2pt}}}%
   \hhrule
   }

\def\vvrule{\vrule width \GL@wd \kern-\GL@wd}

 \def\vRule@{\advance\gridcount 2%
   \hfil\vvrule\hfil
   \setbox\auxGridbox@=\vbox to 0pt
      {\vskip \Htt@\vskip 2pt
        \hbox to 0pt{\hss\L@Dc\number\gridcount\Zr@s\hss}\vss}%
      \wd\auxGridbox@=0pt \box\auxGridbox@
   \vvrule
   }

 \def\PlaceGrid@@{\gridcount=10 
  \setbox\hGridbox@=\hbox{%
        \hbox{%
             \hskip-.4pt\vrule
             \vbox to \Htt@{%
               \offinterlineskip\parindent=\z@\relax
               \hbox to \Wdd@{\hfil}
               \hRule@\hRule@\hRule@\hRule@
               \vfil\hhrule\vfil}%
             \vrule\hskip-.4pt}
    }%
  \gridcount=0%
  %
  \setbox\vGridbox@=\hbox{%
      \vbox{\offinterlineskip\parindent=0pt\hsize=0pt
         \vskip-.4pt\hrule%
         \hbox to \Wdd@{%
                 \vtop to \Htt@{\vfil}%
                 \vRule@\vRule@\vRule@\vRule@
                 \hfil\vvrule\hfil}%
         \hrule\vskip-.4pt}}%
  %
  \wd\hGridbox@=0pt\ht\hGridbox@=0pt
  \wd\vGridbox@=0pt\ht\vGridbox@=0pt
  %
  \hbox{\box\hGridbox@\box\vGridbox@}%
  }

 \def\LabelsGlobal{\def\LabGl@b{\global}}
 \def\LabelsLocal{\def\LabGl@b{}}
 \LabelsGlobal %% default

 \def\SetLabels#1\endSetLabels{%
   \LabGl@b\Labeltoks@={#1()\\}%
   }

 \LabGl@b\Labeltoks@={()\\}

 \def\ShowGrid{\LabGl@b\let\PlaceGrid@\PlaceGrid@@}
 \def\HideGrid{\LabGl@b\let\PlaceGrid@\relax}
 \def\Grids{\ShowGrid\LabGl@b\let\GridSwitch@\ShowGrid}
 \def\noGrids{\HideGrid\LabGl@b\let\GridSwitch@\HideGrid}

 \noGrids

 \def\bAdjust@@{%
     \setbox\auxLabelbox@=\hbox{\raise \dp\auxLabelbox@
            \box\auxLabelbox@}}
 \def\bAdjust@{\let\vAdjust@\bAdjust@@}

 \def\eAdjust@@{\dimen0=-.5\ht\auxLabelbox@
     \advance\dimen0 by .5\dp\auxLabelbox@
     \setbox\auxLabelbox@=
            \hbox{\raise\dimen0\box\auxLabelbox@}}
 \def\eAdjust@{\let\vAdjust@\eAdjust@@}

 \def\tAdjust@@{%
     \setbox\auxLabelbox@=\hbox{\raise-\ht\auxLabelbox@
            \box\auxLabelbox@}}
 \def\tAdjust@{\let\vAdjust@\tAdjust@@}

 \let\vAdjust@\relax

 \def\lAdjust@{\let\hAdjust@\rlap}
 \def\rAdjust@{\let\hAdjust@\llap}

 \let\hAdjust@\relax\let\vAdjust@\relax

 \def\FetchLabel@#1(#2)#3\\{%
     \IN@0#2@@\ifIN@
        \setbox0=\hbox{\ignorespaces#1#3\unskip}%
        \ifdim\wd0>0pt
           \ms@g{}%
           \ms@g{ !!! Bad label(s)? !!!}%
           \message{ #1(#2)#3}%
        \fi
        \def\LabelMole@##1\endFetchLabel@{%
            \IN@0()\\@##1@%
            \ifIN@\def\Temp@{\FetchLabel@##1\endFetchLabel@}%
            \else\def\Temp@{}%
            \fi
            \Temp@
           }%
     \else
       \ignorespaces#1\unskip
       \setbox\auxLabelbox@=%
         \hbox to 0pt{\hss\ignorespaces\hAdjust@
          {\ignorespaces#3\unskip}\hss}%
       \vAdjust@
       \let\hAdjust@\relax\let\vAdjust@\relax
       \AugmentLabelBox@@{#2}%
       \ht\Labelbox@=0pt\dp\Labelbox@=0pt
       \let\LabelMole@\FetchLabel@%
     \fi\LabelMole@}

 \newtoks\XYSep@ %\XYSep@{*}
 \def\SetXYSeparator#1{%
     \IN@0#1@@\ifIN@\XYSep@{*}%
     \else
     \XYSep@{#1}%
     \fi
     }

 \SetXYSeparator*

 \def\AugmentLabelBox@@#1{%
     \IN@0\the\XYSep@ @#1@\ifIN@
       \SPLIT@0\the\XYSep@ @#1@%
       \setbox\Labelbox@=\hbox to 0pt{%
         \unhbox\Labelbox@
         \Shifted@@{\the\Initialtoks@\Wddd@}%
         {\the\Terminaltoks@\Httt@}%
         {\box\auxLabelbox@}}%
     \else
         \ms@g{}%
         \ms@g{ !!! Bad insertion point. !!!}%
         \message{ (#1\ this point was rejected.)}%
     \fi
    }
 
 
 \def\FetchOption@#1[#2]#3\endFetchOption@{%
    \def\temp{#1}%\show\temp
    \ifx\temp\empty
       \Edgect@=#2\relax%\showthe\Edgect@
       \let\EdgGl@b\relax
       \SetEdges@%\def\Edgescale@##1{\divide##1 by \Edgect@\relax}%
       %\show\Edgescale@
       \Cleaner@#3%
       %\showthe\Labeltoks@
    \fi}

 \def\Cleaner@#1[@]{\Labeltoks@{#1}}
     
 \def\PlaceLabels@@{\mathsurround=0pt%\bgroup
     \def\Cr@{\\}%
     \let\L\lAdjust@\let\R\rAdjust@
     \let\B\bAdjust@\let\E\eAdjust@\let\T\tAdjust@
     \expandafter\FetchOption@\the\Labeltoks@[@]\endFetchOption@
     \Wddd@=\Wdd@ \Edgescale@\Wddd@ %\showthe\Edgect@
     \Httt@=\Htt@ \Edgescale@\Httt@
     \expandafter\FetchLabel@\the\Labeltoks@\endFetchLabel@
     \box\Labelbox@%\egroup
     }%

 \let \PlaceLabels@\PlaceLabels@@

 \def\AffixLabels#1{\setbox\Coordinatebox@=\hbox{#1}%
      \Wdd@=\wd\Coordinatebox@ \Htt@=\ht\Coordinatebox@
      \advance\Htt@ \dp\Coordinatebox@
      \hbox{\copy\Coordinatebox@\kern-\Wdd@ 
           \Shifted@@{0pt}{-\dp\Coordinatebox@}%
           {\PlaceLabels@\PlaceGrid@}%
           \kern\Wdd@}%
      \GridSwitch@ %% next grid hidden
      \LabGl@b\Labeltoks@{()\\}%
      }
 
 %%% Restoring
   \let\wlog\LabelFigwlog@ld   %%restore logging
   \catcode`\@=\LabelFigCatAt  %%12 or 13

  \endinput

 %% end of  labelfig.tex



 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %% labelfig.doc
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%
 %%%%%   LABELFIG.TEX FOR LABELLING TEX FIGURE INSERTS %%%%%
  %%
  %%                        DOCUMENTATION
  %%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
                                By

              Raymond S\'eroul <A18645@FRCCSC21.BITNET>
                                and 
              Laurent Siebenmann <lcs@topo.math.u-psud.fr>
    
              VERSIONS: July 1991, Oct 1991, Jan 1992, July 1992


INTRODUCTION

      This labelling package is intended for TeX users who
rely on non-TeX sources for for their graphics inserts.  It
provides means for adding TeX labels to such inserts with a
minimum of fuss. 

       For most labels, TeX users have in the past found it
reasonably convenient to rely on non-TeX sources. Typical
occasions when an inescapable need for TeX labels seemed to
arise are

 (a) when the graphics program lacks certain exotic or complex
mathematical symbols

 (b) when the very highest typographical quality is wanted for the
labels

 (c) when labels included with the graphics fail to print, 
 and you cannot figure out why (cf. boxedeps.doc).  The labels
 provided by labelfig.tex are 100% portable.

       Since this package first appeared, many users, who in the
past scarcely dreamed of using TeX labels, have come to use
nothing but.  So it is now appropriate to add

Intoxication Warning:  TeX labels may be addictive and expensive. 

     If you have a fast preview you may disagree, and even find
that this package provides an agreeable paste-up environment; see
extra applications at end.

     Note to publishers: It is possible and convenient to ultimately
export the TeX labels produced by labelfig.tex to become an integral
part of the EPS file. This is often desired by a publisher who typically
uses an "upmarket" graphics or page layout program, with which the
staff is skilled in perfecting figures.  See Appendix I for
a recipe.

     The authors are grateful to Patrick Ion of Math Reviews for
helpful comments and encouragement.


BASIC INSTRUCTIONS

    After reading in the macro file using

    \input labelfig.tex

preview or proof your figure with a coordinate grid printed on
top, by typing the following:

    \ShowGrid  % shows grid  for next figure only
    \AffixLabels{<the graphics insertion>}

Here <the graphics insertion> is what you would type to insert
the graphics object alone without the grid.  This must provide
for the space around it. For example <the graphics insertion>
might well be \BoxedEPSF{MyFigure scaled 700} using the
boxedeps.tex macro package (from same source); this provides a
TeX box containing the encapsulated PostScript insert specified by
the file MyFigure. \AffixLabels{...} provides the grid (supposing
\ShowGrid is present) and later, once you have specified labels
using the grid, it will "tack on" the labels.

     The grid is a sort of (usually elongated) checkerboard of
ten rows and ten columns and its (internal) partitions are by
default numbered  .1, ... ,.9  both horizontally (X-coordinate
running left to right) and vertically (Y-coordinate running bottom
to top).  Thus the points enclosed by the grid correspond to the
points of the unit square in the cartesian "X-Y" plane, the lower
left corner corresponding to the origin (0,0).  By extrapolation,
the full page corresponds to a larger rectangle in the plane.

     These coordinates serve to position labels as follows.
Before the \AffixLabels{...} command type label specifications:

  \SetLabels
   (<X-coordinate>*<Y-coordinate>) <first label> \\
   .
   .
   .
   (<X-coordinate>*<Y-coordinate>)  <last label> \\
  \endSetLabels

Each row specifies one label and is terminated by \\.  In each
row, the position indicator comes first; it is written as a
standard cartesian point except that the X- and Y- coordinates
are separated by * rather than a comma because TeX allows a
comma as decimal point. There are no dimension units to specify
as the unit is the grid itself.

     By default, this cartesian point specifies where the middle
of the baseline of the label will be located.  However if you precede
the point by \L [or \R] the left [or right] edge of the baseline will
be located there. Similarly you may also precede the point by \T, \E,
or \B to vertically align the top equator or bottom of the label box
at the specified point.  This gives nine standard positions of
the label with respect to the insertion point --- corresponding to
the eight principle points of the compas and the center

                     \L\T     \T      \R\T

                     \L\E     \E      \R\E

                     \L\B     \B      \R\B

But this neglects the default "baseline" level of TeX,
giving potentially three more positions

                     \L    <no tag>   \R

For text, the baseline level is often the preferred. Its relation to
the others is variable. It will often coincide with the bottom level,
as happens for "X".  But it is often distinct, as for "g", in which
case you have in all 12 distinct positions rather than 9.

     It is convenient to think of this specification of label
position as attaching the label by a thumb-tack to the coordinate
grid. There are up to twelve positions of the thumb-tack on the
label, while the position of the thumb-tack on the coordinate grid is
arbitrary.  Normally, one choses the position of the thumb-tack on
the label to be the one that is the closest to the item being
labeled.  There are good reasons for this "rule of thumb":

   (a)  It facilitates correct positioning at first try.

   (b)  If the scale of the figure must be altered after labels
have been affixed, the labels have a good chance of remaining well
positioned.

   (c)  The visible grid need not extend beyond the "bounding box"
for the figure, because the best preferred position is always
(at least almost) within the bounding box .

The second reason is particularly important. Indeed it often
happens that scale has to be altered after labelling begins, in
order to either provide space for the labels, or to adjust
proportions between the labels and the figure.  (The size of labels
is unaffected by scaling.)

     Here is an artificial but self-contained test which uses
TeX rules to make a graphics object.

TEST

    Do not skip this!

 %%%%%%%%%%%%%%%%%%  --- cut
\input labelfig

 %%%%%% useful ad hoc macros

 %%% \FrameIt#1 frames what it finds in #1
 \def\FrameIt#1{\hbox{\vrule$\vcenter {\hrule\kern3pt%
             \hbox {\kern3pt #1\kern3pt}%
               \kern3pt\hrule}$\relax\vrule}}

 %%% \Caption#1#2 gives framed caption width #1
  %%  containing #2
 \def\Caption#1#2{\FrameIt{%
       \vtop {\hsize=#1\relax \parindent=0pt
         \leftskip=0pt \rightskip=0pt plus15pt
         \parfillskip=0pt
         \lineskip=1pt\baselineskip=0pt
         #2}}}

 \def\FirstQuadrant{\hbox to 100pt{\vrule\vbox to 100pt{%
        \hbox to 100pt{\hfil}\vfil\hrule}\hss}}

 %%% the test proper begins

  \SetLabels
    \R(.5*.2) $\zeta\,\cdot$\\
    (.9*-.10) $\xi$\\
    \R(-.03*.9) $\eta$\\
    \T(.5*.9) \Caption{70pt}{%
          \it The norm of
          $g(\xi+i\eta)$ is indicated on
          contours of this invisible surface.}\\
  \endSetLabels

  %\ShowGrid  % this makes the grid visible (once)
  \AffixLabels{\FirstQuadrant}

  \end

  Note that the coordinates to use for labels are indicated on the
edges of the grid (when visible) corresponding to the conventional
x- and y- axes of the Cartesian plane. By default the grid is
1-by-1. However, by the command \Edges{100}, you can change this
to 100-by-100 and many users find this alternative most
convenient. Place the command \Edges{...} in your style file (or
header) since its effect is is global. Other possible edge values
are 10 and 1000.

  If you use the command \Edges{...} at all, do so with care.  For
if you accidentally delete an \Edges{...} command your labels will
abruptly be badly misplaced and may logically but mysteriously
generate "dimension too big" errors under TeX and "off page" errors
under your driver.  

  You can dictate the edgescale for an individual figure by giving
the scale in brackets immediately after \SetLabels.  Thus, to
import into an article using say \Edge{100} a figure labelled using
another edgescale, say the original 1-by-1 default, you can use
\SetLabels[1]...\endSetLabels.


 %%%%%%%%%%%%%%%%%% --- cut

 
GETTING IT DOWN PAT

     Complicated labeling deserves the same respect as
complicated mathematics.  Do not expect it to come out perfect the
first time!  What is needed in either case is a mechanism to
repeatedly typeset troublesome pieces.

     One mechanism is always available.  One does complicated
labelling in a separate "test" file involving just the figure being
labelled;  a texpert will know how to \dump TeX's current state as
a temporary format that restarts rapidly at each retry.  Usually,
one then pastes the completed labelled figure back into the main
TeX file, but, of course, one can also \input it as an auxiliary
file.

     If you do not have a TeXpert at handy, here is a first
approximation to an efficient setup. By deletions reduce a copy
of your article to just a few lines before and after the figure.
Now label the figure, and finally, copy and paste the labelled
figure to the original article. Then copy the next figure to label
into this testbed and repeat. The TeXpert can improve the  speed
at which TeX starts up, by compiling a format specifically for
your article; just one caution: best NOT include in the format
ephemeral details of setup like \Set<mydriver>ArtSpecials (from
boxedeps.tex because this reads  figure dimensions which you may
change during your work session.

     An improved mechanism to repeatedly typeset troublesome
pieces is now available on the Macintosh; it is called LinoTeX;
see the same ftp sources.  It could be set up on many types
of computer.

     Before using labelfig.tex to attach labels to a graphics
object inserted using boxedeps.tex or BoxedArt.tex, make it a
firm rule to carefully adjust the bounding box using the trimming
commands of these packages, and also at least tentatively scale
and position the object. Beware of changing the grid inadvertently
after the labels have been positioned.  For example, correcting
the bounding box of a PostScript graphics object can foul up the
labels by changing the coordinate grid to which the labels are
attached. This is particularly true for the trimming  commands of
boxedeps.tex and BoxedArt.tex. However, as noted already, change
of scale is much less disruptive, and modest adjustments should be
well tolerated.

     Sometimes the labels protrude so far from the bounding box
of a figure that the figure has to be repositioned.  Best do this
by ad hoc spacing, say using \hglue and \vglue; altering the
bounding box would create a vicious circle.

     Remember that you are responsible for preventing labels
from overlapping. You are responsible for all label typography
including size and style. A label is really just about anything
that can be put in a TeX box. Note that spaces at the beginning
and end of labels will normally be suppressed; if you really want
them you must protect them with TeX braces.

     This package temporarily sets the \mathsurround parameter
of TeX to zero  while the labels are being affixed. This is done
because nonzero \mathsurround space would influence the position
of left and right aligned labels; then, when a texpert or printer
modifies mathsurround, diagram labeling might be disastrously
altered. There is a small price to pay involving labels that are
formatted as caption boxes including mathematics: you  may want or
need to specify an explicit mathsurround space within the caption
box; it will not influence anything outside.

     Those hostile to the use of * as separator between
the X and Y coordinates of label insertion points, are free to
impose another using \SetXYSeparator{<the new separator>}.  
Americans may prefer "," to "*" since they never use a 
comma as a decimal point; on the other hand, * may be more visible.



APPENDIX (I)  MERGING labelfig.tex LABELS INTO AN EPSF GRAPHICS OBJECT.

     As promised in the introduction, here is a recipe useful for
publishers. It works at least on Macintosh and at least for vectorized
graphics and Adobe type1 fonts.  (There is surely a similar recipe for
PCs under MSWindows.)

 (a)  Use boxedeps.tex utility to integrate the figure given by the eps
file, "x.eps" say, with a visible frame around it.  See
\ShowDisplacementBoxes command in boxedeps.tex.  To get precise results
automatically it is important to use the \Trim... commands of
boxedeps.tex making the "DisplacementBox" neatly fit the figure.

 (b)  Use the TeX printer driver and LaserWriter (versions >= 8.1.1) to
export to an EPSF the DVI page containing the integrated, labelled
figure. You now have an EPS file  "xx.eps"  that contains too much, and at
the wrong scale, and at wrong position.

 (c)  Convert the EPSF to an Adode Illustrator format EPSF using
the shareware utility called epsConvert by Sam Weiss
1993-- (currently $25).

 (d)  In Illustrator (or a compatible program), group the labels and the
"DisplacementBox"; copy them to the clipboard and paste them into "x.ps".
This step requires that all the label fonts be "visible to the Macintosh.

 (e)  Translate and scale the pasted group consisting of the labels plus
the "DisplacementBox" so as to make the "DisplacementBox" the bounding
box of (labelless) figure represented by "x.eps".  At this point the
labels will be correctly placed on the figure "x.eps".

 (f)  Ungroup and delete the "DisplacementBox".  The result is the
desired single EPS file, "x+.eps" say, It contains the original figure
plus its labels.  

     Using grouping and ungrouping appropriately in "x+.eps", a
publisher's staff can very efficiently improve label positions etc.



APPENDIX II)  SOME EXOTIC APPLICATIONS

     The grid of labelfig.tex is analogous to a light-table in
classical page makeup with wax or latex glue.  In principle, you
can use it to compose any page from its indivisible parts.  This
even has some of the artisanal charm of classical paste-up
provided you have a fast screen preview to make the process
"interactive".

     In practice labelfig.tex is a tool for nonstandard jobs.
Here are a few going beyond the labelling already discussed.



(I)  GRAPHICS INTEGRATION.

     This is accomplished by treating the imported graphics
objects as labels.  The underlying graphics object is then
typically an empty  \vbox to <dimension>{\vfill} in a TeX
\midinsert...\endinsert construction.  A label line
might be of the form

   (.1*.1) \special{... MyFigure ...}\\

The exact form of the special command varies from driver to
driver.  However, in the case of encapsulated PostScript graphics
(EPSF norm), by relying on boxedeps.tex, one can have the
following standard syntax (independant of driver  (see
boxedeps.doc for details.
  
  (.1*.1) \BoxedEPSF{MyFigure scaled <scale in mils>}\\

This may be slow since it requires TeX to read the PostScript
file to read bounding box using many complex macros.  So you
may want to try

  (.1*.1) \EPSFSpecial{MyFigure}{<scale in mils>}\\

which is fast and driver independant, but it squashes the
bounding box, normally to its lower left corner.

     Similarly for graphics of the Macintosh PICT norm ---
using BoxedArt.tex (same sources) in place of boxedeps.tex.

     This approach to integration is to be recommended when
one is assembling a composite graphics object.


 (II)  COMMUTATIVE DIAGRAM ENHANCEMENT

     Commutative diagrams or arrays of mathematical objects
connected by arrows of various sorts are common in mathematics.
The mathematical objects require the use of TeX.  Recently TeX
acquired a good collection of arrows of all slopes --- that of
LamSTeX --- plus pwerful macros to build the diagrams.

     However, even the LamSTeX collection is often
inadequate; it lacks for example double shafted arrows, dotted
arrows and curved arrows. Fortunately it is possible to produce
such arrows on an individual basis using sophisticated graphics
programs such as Illustrator and AldusFreehand (both serving
the EPSF norm) or using Metafont (with its public domain norm).
Since the creation of each new arrow is a work of love, you
probably want to limit the number of arrows by using LamSTeX
for most arrows. The 40K commutative diagram module of LamSTeX
has been adapted to work with AmSTeX and a copy may be posted
with LabelFig and related files. Unfortunately no one has yet
offered a version that works with Plain TeX or LaTeX.

       Suffice it here to say that when the exotic arrow has
been somehow imported into TeX, labelfig.tex treats it as a
label that one affixes to the commutative diagram.  Two other
steps will be treated in separate notes, namely the matter of
extracting the dimension specifications for the arrow and the
construction of the arrow --- for these steps are far from
unique and often depend intimately on your computer environment. 
Notes for the Macintosh-Textures-Illustrator combination are
found in the file ExoticArrows.doc.


 (III) NESTING 

Ingenuity pays off in exploiting labelfig.tex. One can
mix graphics and typography quite freely.  labelfig.tex is good
for freeform or overlapping arrangements, while boxedeps.tex (or
BoxedArt.tex) is best for regimented non-overlapping
arrangements --- and the two can be combined.

     The default behavior of labelfig.tex is not ideal 
for nesting objects, because to prevent trouble for beginners
the register for labels is globally cleared when \AffixLabels
concludes.  But there are switches available

      \LabelsGlobal      \LabelsLocal

which change this.  To understand this, extend the above test 
by something like:

 %%%%%%%%%%%%%%%%%% --- cut
 %%% Test extension

 \LabelsLocal
 %\LabelsGlobal

 \SetLabels
    (.5*.5) AAA\\
 \endSetLabels

 {%%% Watch for influence of braces!!
 \SetLabels
    (.5*.5) ZZZ\\
 \endSetLabels
   \AffixLabels{\FirstQuadrant}
 }

   \AffixLabels{\FirstQuadrant}

 %%%%%%%%%%%%%%%%%% --- cut

     There are however potential pitfalls.  Neither
labelfig.tex nor boxedeps.tex has been tested under extreme
conditions. Problems may occur if their procedures are
indiscriminately nested. For boxedeps.tex (not labelfig.tex)
there is a precise cause for worry, namely many of its
variables are "global", which means that TeX braces will not
provide the protection one might expect.
 

COMMAND SUMMARY FOR labelfig.tex

  Here [...] means optional (one or zero)
       [...]* means any number of such constructs

  \SetLabels
    [[<P>](<X><Sep><Y>) <label> \\]*
  \endSetLabels
  \ShowGrid  % this makes the grid visible (once)
  \AffixLabels{<the figure>}

   --- <P> is tack position, one of eleven or empty
              order irrelevant

                   \L\T      \T      \R\T

                   \L\E      \E      \R\E

                     \L               \R

                   \L\B      \B      \R\B

   --- (<X><Sep><Y>) insertion point;
  <Sep> is separator, = * by default;
  \SetXYSeparator{<Sep>} changes it.
   <X> and <Y> are real numbers

  --- <label> a label to attach 

  --- <the figure> the figure to label 

  \GlobalLabels (default)     
  \LocalLabels  setting for nested constructs.

 \Grids makes ALL grids appear; \HideGrid then makes just next disappear.
 \noGrids returns to default.  The commands are always global.

 \GridLineWidth{<dimension>} adjusts width of grid lines. Default is very
small, to give "hairline" effect. If your grid lines are missing try
setting \GridLineWidth{1pt}.

 \Edges#1 globally changes the edge size of all grids to the numerical 
value #1, which must be 1, 10, 100, or 1000.  The default is 1.


VERSION HISTORY.
 --- Jan 1993: \Edges#1 and [??] option after \SetLabels
 --- July 1992: \Grids, \noGrids, \HideGrid;
       Gridlines become hairlines; \GridLineWidth{<dimension>}.
 --- Oct 1991, Jan 1992: \SetXYSeparator{<Sep>},  \LabelsGlobal,
       \LabelsLocal.
 --- July 1991: first release

Address for bugs and other feedback:

        Raymond S\'eroul
        IREM and Lab. de Typographie Informatise
        Univ. Rene Descartes
        Strasbourg

    Tel 33-88-41-63-45
    Email:  A18645@FRCCSC21.BITNET


        Laurent Siebenmann
        Mathematique, Bat. 425,
        Univ de Paris-Sud,
        91405-Orsay,
        France

    Tel 33-1-6941-7949; 
    Email: lcs@topo.math.u-psud.fr  


