 %%%%%%%%%%%%%%%%%%%--------------- CUT
 
  %%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%
 %%%%%   LabelFig.tex FOR LABELLING FIGURE INSERTS %%%%%
  %%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%
 %%%  AUTHOR: Laurent Siebenmann
  %%    lcs@matups.matups.fr
  %%
 %%%  VERSION: July 1991
  %%
 %%%  PURPOSE:
  %%  Occasionally, figures imported into TeX lack some labels.
  %%  It may then be most convenient to use TeX to provide
  %%  the labels.  Several macro sets, notably the
  %%  LaTeX picture environment, provide means to insert
  %%  labels.  LabelFig.tex is a small (4Ko) and fast macro file
  %%  offering labelling capability for other TeX formats such
  %%  as Plain and AmSTeX.  Hopefully it will work in essentially
  %%  all TeX environments.
  %%
 %%%  THE IDEA:
  %%  Nothing distinctly new here.
  %%  Each label is located with respect
  %%  to a grid laid down on the figure --- as in LaTeX.
  %%  The device of using TeX to print the grid in proof versions
  %%  is apparently not in LaTeX but has been since used by
  %%  others.  Many thanks to to Raymond Seroul (Strassbourg) for
  %%  pointing it out to me back in 1989.
  %%  (It was used in a Plain TeX hack of the picture
  %%  environment by Desarmenien, Ostromoukhov, and Seroule
  %%  that seems not to have been released.)
  %%
 %%%  POSTINGS (soon!!): anonymous ftp
  %%  ---  ftp 28.146.7.200 (alias shape.mps.ohio-state.edu);
  %%  login: anonymous;  password: <anything>;
  %%  directory pub/osutex
  %%  ---  ftp 130.84.128.100 (alias rsovax.circe.fr);
  %%  login: anonymous; password: <anything>; directory
  %%  [anonymous.siebenmann]
  %%
 %%%% DOCUMENTATION:
  %%  --- see Labelfig.doc
  %% (may be included at end, after \endinput)
  %%
 %%%% EXAMPLE OF USAGE:
  %%    \input LabelFig.tex
  %%    \SetLabels
  %%      (.3*.7) first label\\
  %%         % 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 or \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
  %%         % covering the inserted figure to be labelled.
  %%         % (Here \BoxedEPSF is the figure insertion macro
  %%         % of my 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
  \else
    \immediate\write16{ !!! 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
 
 \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@
  \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}
 
   %%% \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\box0\kern-#1}%
           \kern#2}}
 
 
 
 \newcount\gridcount
 \newbox\auxGridbox@ \newbox\hGridbox@ \newbox\vGridbox@
 \newbox\Labelbox@ \newbox\auxLabelbox@
 \newbox\Coordinatebox@
 \newtoks\Labeltoks@
 \newdimen\Wdd@ \newdimen\Htt@
 
 \def\hRule@{\advance\gridcount -2%
   \vskip-.2pt\hrule\vskip-.2pt\vfil
   \llap{\smash{\raise -2.5pt
     \hbox{.\number\gridcount\kern2pt}}}%
           \vskip-.2pt\hrule\vskip-.2pt\vfil}
 
 \def\vRule@{\advance\gridcount 2%
   \hskip-.2pt\vrule\hskip-.2pt\hfil
   \setbox\auxGridbox@=\vbox to 0pt
      {\vskip \Htt@\vskip 2pt
        \hbox{\kern-3.5pt.\number\gridcount}\vss}%
      \wd\auxGridbox@=0pt \box\auxGridbox@
   \hskip-.2pt\vrule\hskip-.2pt\hfil}
 
 \def\PlaceGrid@@{\gridcount=10%
  \setbox\hGridbox@=%
    \hbox{\hbox{\GridSpider@{\hskip-.4pt\vrule}%
             \vbox to \Htt@{\offinterlineskip\parindent=\z@%
                \GridSpider@{\vskip-.4pt\hrule}\vfil
                \hRule@\hRule@\hRule@\hRule@
                  \vskip-.2pt\hrule\vskip-.2pt\vfil
                \hbox to \Wdd@{\hfil}%
             \GridSpider@{\hrule\vskip-.4pt}}%
         \GridSpider@{\vrule\hskip-.4pt}}}%
  \gridcount=0%
  \setbox\vGridbox@=
     \hbox{\vbox{\offinterlineskip\parindent=0pt\hsize=0pt
       \GridSpider@{\vskip-.4pt\hrule}%
             \hbox to \Wdd@{%
                \GridSpider@{\hskip-.4pt\vrule}\hfil
                \vtop to \Htt@{\vfil}%
                     \vRule@\vRule@\vRule@\vRule@
                     \hskip-.2pt\vrule\hskip-.2pt\hfil
             \GridSpider@{\vrule\hskip-.4pt}}%
         \GridSpider@{\hrule\vskip-.4pt}}}%
  %
  \wd\hGridbox@=0pt\ht\hGridbox@=0pt
  \wd\vGridbox@=0pt\ht\vGridbox@=0pt
  %
 \hbox{\box\hGridbox@\box\vGridbox@}%
  }
 
 \def\SetLabels#1\endSetLabels{%
   \Labeltoks@={#1}}
 
 \def\GridSpider@#1{#1}
 \let\PlaceGrid@\relax
 \def\ShowGrid{\let\PlaceGrid@\PlaceGrid@@}
 
 \def\bAdjust@@{%
     \setbox\auxLabelbox@=\hbox{\raise \dp\auxLabelbox@
            \box\auxLabelbox@}}
 \def\bAdjust@{\let\vAdjust@\bAdjust@@}
 
 \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)#4\\#5\endFetchLabel@{%
     %\globaldefs=1\setbox0=\hbox{#1}\globaldefs=0%
     \ignorespaces#1\unskip
     \Labeltoks@={#5}%
     \setbox\auxLabelbox@=%
        \hbox to 0pt{\hss\ignorespaces\hAdjust@
          {\ignorespaces#4\unskip}\hss}%
     \vAdjust@
     \let\hAdjust@\relax\let\vAdjust@\relax
     \setbox\Labelbox@=\hbox to 0pt{%
       \box\Labelbox@
       \Shifted@@{#2\Wdd@}{#3\Htt@}{\box\auxLabelbox@}}%
     \ht\Labelbox@=0pt\dp\Labelbox@=0pt
     }
 
 \def\PlaceLabels@@{\bgroup\def\Cr@{\\}%
     \let\L\lAdjust@\let\R\rAdjust@
     \let\B\bAdjust@\let\T\tAdjust@
     \loop
     \IN@0\Cr@ @\the\Labeltoks@ @\relax
     \ifIN@ \expandafter
       \FetchLabel@\the\Labeltoks@\endFetchLabel@
     \repeat
     \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@}%
            {\PlaceGrid@\PlaceLabels@}%
           \kern\Wdd@}}
 
 %%% Restoring
   \let\wlog\LabelFigwlog@ld %%restore logging
   \catcode`\@=\LabelFigCatAt  %%12 or 13
 
  \endinput
 
 %% end of  LabelFig.tex
