% This is labtex, v 0.9.

% written by:   Alan Hoenig, summer 1991-summer 1992.
%       Bitnet: ajhjj@cunyvm
%       Mail: 17 Bay Avenue, Huntington, NY 11743, USA
%

% You need the file LABTEX.MF in addition to this one.  
% shortly modified (i.e. shortened) by Karel Hor k, November 1, 1992 

\chardef\atcode=\the\catcode`\@
\catcode`@ 11

\newdimen\unit \unit=1truemm
\newcount\labels
{\catcode`.=12 \catcode`p=12 \catcode`t=12
 \gdef\\#1.#2pt{\global\labels=#1
 }}\let\glpf=\\
\global\let\\=\relax

\def\getx#1{\setbox2=\hbox{\OBR\char255 \char#1}%
 \setbox0=\hbox{\OBR\char255{}\char#1}%
 \dimen0=\wd2 \advance\dimen0 by-\wd0
}
\def\gety#1{\setbox2=\hbox{\OBR\char254 \char#1}%
 \setbox0=\hbox{\OBR\char254{}\char#1}%
 \dimen0=\wd2 \advance\dimen0 by-\wd0
}
\def\readfname #1 #2<{\def\fn@me{#1}}
\def\getlpf#1{\expandafter\readfname\fontname\OBR\space{}
                 <\font\OBR@\fn@me
\setbox2=\hbox{\OBR@\char253 \char#1}%
 \setbox0=\hbox{\OBR@\char253{}\char#1}%
 \dimen0=\wd2 \advance\dimen0 by-\wd0
}                                                         %is used
\newdimen\x@ \newdimen\y@

\newcount\scratch \newcount\totallabs \newcount\coordcount
\def\setXYpointers#1{\scratch=0 \totallabs=0%
 \coordcount=0 % start with fresh slate
 \loop\ifnum\scratch<#1%
  \getlpf\scratch \expandafter\glpf\the\dimen0
  \advance\totallabs by\labels
  \advance\scratch by 1 \repeat
 \global\coordcount=\totallabs
}
\def\labtex #1 {\setXYpointers{#1}}
% ensures \coordcount's value is the char whose kern
% is \x@; same for \y@

\newdimen\extradx \newdimen\extrady \newtoks\everylabel
\newbox\labelbox \newdimen\totalht
\newdimen\labelht \newdimen\labelwd \newdimen\labeldp
\newdimen\vertadjust \newdimen\horadjust% vertical adjustment of labels
\def\getparameters#1{% #1 is text of label
 \global\vertadjust=0pt \global\horadjust=0pt 
 \setbox\labelbox=\hbox{\the\everylabel #1}%
 \labelht=\ht\labelbox \labeldp=\dp\labelbox 
 \advance\labelht by\extrady \advance\labeldp by\extrady
 \totalht=\labelht \advance\totalht by\labeldp
 \setbox\labelbox=\hbox{\the\everylabel 
  \vrule width0pt height\labelht depth\labeldp
  \hskip\extradx #1\hskip\extradx}\labelwd=\wd\labelbox %
% \ifdebug \showthe\coordcount \fi 
 \getx\coordcount \x@=\dimen0 \advance\x@ by\horadjust
% \ifdebug \showthe\dimen0 \fi % \x@ before \horadjust
 \gety\coordcount \y@=\dimen0 \advance\y@ by\vertadjust
% \ifdebug \showthe\dimen0 \fi % \y@ before \vertadjust
% \ifdebug \showthe\x@ \showthe\y@ \fi % after adjustments
 \global\advance\coordcount by1 
}
\def\down{\global\vertadjust= -}
\def\up{\global\vertadjust= }
\def\toleft{\global\horadjust= -}
\def\toright{\global\horadjust= }
\def\xy #1,#2 
        {\global\horadjust=#1\unit\global\vertadjust=#2\unit}

\def\reset{% puts ref pt of \labelbox at lower left, not at baseline
 \advance\y@ by \labeldp}

\def\point #1; {\getparameters{\rm$#1$}% point to left end of Baseline
 \leavevmode\rlap{\kern\x@ \raise\y@ \box\labelbox}}

\let\Bpoint=\point \let\Blpoint=\point \let\lBpoint=\point % synonyms

\def\Brpoint#1; {\getparameters{\rm$#1$}%
\advance\x@ by-\labelwd
 \leavevmode\rlap{\kern\x@ \raise\y@ \box\labelbox}}
\let\rBpoint=\Brpoint 

\def\cpoint#1; {\getparameters{\rm$#1$}% OK
 \reset \advance\y@ by-.5\totalht \advance\x@ by-.5\labelwd
 \leavevmode\rlap{\kern\x@ \raise\y@ \box\labelbox}}

\def\lpoint#1; {\getparameters{\rm$#1$}% OK
 \reset \advance\y@ by-.5\totalht
 \leavevmode\rlap{\kern\x@ \raise\y@ \box\labelbox}}

\def\lbpoint#1; {\getparameters{\rm$#1$}%
 \reset \leavevmode\rlap{\kern\x@ \raise\y@ \box\labelbox}}
\let\blpoint=\lbpoint

\def\bpoint#1; {\getparameters{\rm$#1$}%
 \reset \advance\x@ by-.5\labelwd
 \leavevmode\rlap{\kern\x@ \raise\y@ \box\labelbox}}

\def\rbpoint#1; {\getparameters{\rm$#1$}%
 \reset \advance\x@ by-\labelwd
 \leavevmode\rlap{\kern\x@ \raise\y@ \box\labelbox}}
\let\brpoint=\rbpoint

\def\rpoint#1; {\getparameters{\rm$#1$}%
 \reset \advance\y@ by-.5\totalht \advance\x@ by-\labelwd
 \leavevmode\rlap{\kern\x@ \raise\y@ \box\labelbox}}

\def\trpoint#1; {\getparameters{\rm$#1$}%
 \reset \advance\y@ by-\totalht \advance\x@ by-\labelwd
 \leavevmode\rlap{\kern\x@ \raise\y@ \box\labelbox}}
\let\rtpoint=\trpoint

\def\tpoint#1; {\getparameters{\rm$#1$}%
 \reset \advance\y@ by-\totalht
 \advance\x@ by-.5\labelwd
 \leavevmode\rlap{\kern\x@ \raise\y@ \box\labelbox}}

\def\tlpoint#1; {\getparameters{\rm$#1$}%
 \reset \advance\y@ by-\totalht
 \leavevmode\rlap{\kern\x@ \raise\y@ \box\labelbox}}
\let\ltpoint=\tlpoint

\def\resetlabels #1 {\global\advance\coordcount by #1 }
\def\newlabels{\coordcount=0}

\extradx 1mm
\extrady 1mm

\catcode`@=\atcode
\endinput

