%%
%% This is file `olabels.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% labels.dtx  (with options: `package,latex209')
%% Copyright (C) 1993-1994-1995 by Sebastian Rahtz
%% All rights reserved.
%% 
%% Permission is granted to to customize the declarations in this file to
%% serve the needs of your installation.  However, no permission is
%% granted to distribute a modified version of this file under its
%% original name.
%% 
%% File: labels.dtx  Copyright (C) 1993-1994-1995-1998 by Sebastian Rahtz
%%   and Grant Gustafson
%%   Copyright (C) 2002 by Julian Gilbey <jdg@debian.org>
%% All rights reserved.
\NeedsTeXFormat{LaTeX2e}
\newdimen\paperwidth
\paperwidth=8.5in% 297mm for a4paper
\newdimen\paperheight
\paperheight=11in% 210mm for a4paper
\def\settoheight#1#2{\setbox\@tempboxa%
 \hbox{#2}#1\ht\@tempboxa\setbox\@tempboxa\box\voidb@x}
\def\PackageWarning#1#2{\typeout{#1: #2}}
\newif\iflabel@traddimens
\label@traddimenstrue
\newcount\LabelCols
\newcount\LabelRows
\iflabel@traddimens
 \newdimen\LeftBorder
 \newdimen\RightBorder
 \newdimen\TopBorder
 \newdimen\BottomBorder
\else
 \newdimen\LeftPageMargin
 \newdimen\RightPageMargin
 \newdimen\TopPageMargin
 \newdimen\BottomPageMargin
 \newdimen\InterLabelColumn
 \newdimen\InterLabelRow
 \newdimen\LeftLabelBorder
 \newdimen\RightLabelBorder
 \newdimen\TopLabelBorder
 \newdimen\BottomLabelBorder
\fi
\newcount\numberoflabels
\newdimen\label@width
\newdimen\label@height
\newdimen\area@width
\newdimen\area@height
\newdimen\half@label
\newdimen\half@area
\newdimen\addr@width
\newdimen\LabTmp
\newsavebox\this@label
\newcount\label@number
\newcount\skip@labels
\newcount\l@so@far
\newcount\LabelTotal
\newif\ifLabelGrid
\newif\iffirst@label
\newif\ifLabelInfo
\first@labeltrue
\LabelGridfalse
\LabelInfofalse
\ifdim\paperwidth=210mm\relax%
   \LabelCols=3\relax\LabelRows=8\relax% a4paper
\else
   \LabelCols=3\relax\LabelRows=7\relax% letterpaper
\fi%
\iflabel@traddimens
 \LeftBorder=8mm
 \RightBorder=8mm
 \TopBorder=9mm
 \BottomBorder=2mm
\else
 \LeftPageMargin=4mm
 \RightPageMargin=4mm
 \TopPageMargin=5mm
 \BottomPageMargin=5mm
 \InterLabelColumn=0mm
 \InterLabelRow=0mm
 \LeftLabelBorder=5mm
 \RightLabelBorder=5mm
 \TopLabelBorder=4mm
 \BottomLabelBorder=4mm
\fi
\textwidth=\paperwidth
\textheight=\paperheight
\topmargin=-1in
\headheight=0em
\headsep=0em
\topskip=0em
\footskip=0em
\oddsidemargin=-1in
\evensidemargin=-1in
\pagestyle{empty}
\parindent=0em
\parskip=0pt
\iflabel@traddimens
\def\@LabelSetup{%
 \global\label@width\textwidth
 \global\divide\label@width by\LabelCols
 \global\label@height\textheight
 \global\advance\label@height by-\TopBorder
 \global\advance\label@height by-\BottomBorder
 \global\divide\label@height by\LabelRows
 \global\topmargin=-1in\global\advance\topmargin by\TopBorder
 \global\area@width=\label@width
 \global\advance\area@width by -\LeftBorder
 \global\advance\area@width by -\RightBorder
 \ifLabelGrid%
 \global\advance\area@width by-2\fboxsep
 \global\advance\area@width by-2\fboxrule
 \fi
 \ifLabelGrid
 \global\advance\label@height by-2\fboxsep
 \global\advance\label@height by-2\fboxrule
 \fi
 \global\half@label=\label@height\divide\half@label by2\relax
 \global\label@number=1\relax
}
\else
\def\@LabelSetup{%
 \global\label@width\textwidth
 \global\advance\label@width by-\LeftPageMargin
 \global\advance\label@width by-\RightPageMargin
 \global\advance\label@width by-\LabelCols\InterLabelColumn
 \global\advance\label@width by\InterLabelColumn
 \global\divide\label@width by\LabelCols
 \ifdim\label@width<0pt
  \PackageWarning{labels}{Some dimensions are silly: label width
   \the\label@width~is negative!}
  \label@width=0pt
 \fi
 \global\label@height\textheight
 \global\advance\label@height by-\TopPageMargin
 \global\advance\label@height by-\BottomPageMargin
 \global\advance\label@height by-\LabelRows\InterLabelRow
 \global\advance\label@height by\InterLabelRow
 \global\divide\label@height by\LabelRows
 \ifdim\label@height<0pt
  \PackageWarning{labels}{Some dimensions are silly: label height
   \the\label@height~is negative!}
  \label@height=0pt
 \fi
 \global\topmargin=-1in\global\advance\topmargin by\TopPageMargin
 \global\oddsidemargin=-1in\global\advance\oddsidemargin by\LeftPageMargin
 \global\evensidemargin=\oddsidemargin
 \global\area@width=\label@width
 \global\advance\area@width by -\LeftLabelBorder
 \global\advance\area@width by -\RightLabelBorder
 \global\area@height=\label@height
 \global\advance\area@height by -\TopLabelBorder
 \global\advance\area@height by -\BottomLabelBorder
 \global\half@label=\label@height\divide\half@label by 2\relax
 \global\half@area=\area@height\divide\half@area by 2\relax
 \global\label@number=1\relax
}
\fi
\def\LabelSetup{\@LabelSetup
\ifLabelInfo
   \typeout{Control sequences adjustable in the preamble:}
   \typeout{\LabelRows=\the\LabelRows}
   \typeout{\LabelCols=\the\LabelCols}
   \iflabel@traddimens
     \typeout{The newdimens option was not selected; the used parameters are:}
     \TypeoutBlurb{\TopBorder}{\TopBorder}
     \TypeoutBlurb{\BottomBorder}{\BottomBorder}
     \TypeoutBlurb{\LeftBorder}{\LeftBorder}
     \TypeoutBlurb{\RightBorder}{\RightBorder}
   \else
     \typeout{The newdimens option was selected; the used parameters are:}
     \TypeoutBlurb{\TopPageMargin}{\TopPageMargin}
     \TypeoutBlurb{\BottomPageMargin}{\BottomPageMargin}
     \TypeoutBlurb{\LeftPageMargin}{\LeftPageMargin}
     \TypeoutBlurb{\RightPageMargin}{\RightPageMargin}
     \TypeoutBlurb{\InterLabelColumn}{\InterLabelColumn}
     \TypeoutBlurb{\InterLabelRow}{\InterLabelRow}
     \TypeoutBlurb{\TopLabelBorder}{\TopLabelBorder}
     \TypeoutBlurb{\BottomLabelBorder}{\BottomLabelBorder}
     \TypeoutBlurb{\LeftLabelBorder}{\LeftLabelBorder}
     \TypeoutBlurb{\RightLabelBorder}{\RightLabelBorder}
   \fi
   \typeout{Computed values:}
   \TypeoutBlurb{Label Width}{\label@width}
   \TypeoutBlurb{Label Height}{\label@height}
\else
   \typeout{To print info, put `\protect\LabelInfotrue' in the preamble}
\fi
}
\numberoflabels=1%
\def\sticky@label{\l@so@far=0%
 \loop\ifnum\l@so@far<\numberoflabels\advance\l@so@far by 1\make@label%
 \repeat}
\def\make@label{%
 \ifnum\LabelTotal=0\vfill\eject\LabelTotal=\LabelRows\relax
 \multiply\LabelTotal by \LabelCols\fi
 \advance\LabelTotal by -1\relax
 \ifLabelGrid
  \let\boxing@type\framebox
 \else
  \let\boxing@type\makebox
 \fi
 \settowidth{\LabTmp}{\usebox{\this@label}}%
 \ifdim\LabTmp=0cm\let\action=\relax\else\let\action=\BuildB@x\fi
 %\TypeoutBlurb{Box Width}{\LabTmp}%
 \advance\LabTmp by -\area@width
 \ifdim\LabTmp>0cm\relax
 \PkgBlurb{Label too wide}{\LabTmp}\fi
 \settoheight{\LabTmp}%
  {\begin{tabular}{l}\usebox{\this@label}\end{tabular}}%
 %\TypeoutBlurb{Box height}{\LabTmp}%
 \iflabel@traddimens\advance\LabTmp by -\half@label
 \else\advance\LabTmp by -\half@area\fi
 \ifdim\LabTmp>0cm\relax
 \LabTmp=2\LabTmp\PkgBlurb{Label too tall}{\LabTmp}\fi
 \ifnum\skip@labels<\sk@pped\let\action=\BuildB@x\fi
 \action
}
\def\BuildB@x{%
 \iflabel@traddimens
 \boxing@type[\label@width][c]{%
  \rule{0pt}{\label@height}%
  \raisebox{\half@label}[0pt][0pt]{%
   \rule{\LeftBorder}{0pt}%
   \usebox{\this@label}%
   \rule{\RightBorder}{0pt}%
 }}%
 \else
 \begingroup
 \fboxsep=-\fboxrule
 \boxing@type{%
  \vbox to \label@height{%
   \vskip\TopLabelBorder
   \vss
   \hbox to \label@width{%
    \hskip\LeftLabelBorder
    \usebox{\this@label}%
    \hss
   }%
   \vss
   \vskip\BottomLabelBorder
  }%
 }%
 \endgroup
 \fi
 \ifnum\skip@labels<\sk@pped\message{x}\else\message{+}\fi
 \ifnum\label@number=\LabelCols
  \message{|}%
  \endgraf\nointerlineskip
  \iflabel@traddimens\else\vskip\InterLabelRow\fi
  \global\label@number=1
 \else\global\advance\label@number by 1
  \iflabel@traddimens\else\hskip\InterLabelColumn\fi
 \fi
}
\newcount\@Milli
\def\ToMilli#1{\@Milli=#1\advance\@Milli by93225\relax
\divide\@Milli by 186450\relax}
\def\PkgBlurb#1#2{\ToMilli{#2}%
 \PackageWarning{labels}{#1 by \the\@Milli mm (\the #2)}%
}
\def\TypeoutBlurb#1#2{\ToMilli{#2}%
 \typeout{#1=\the\@Milli mm (\the #2)}%
}
\newcommand{\genericlabel}[1]{%
 \iffirst@label\LabelSetup\first@labelfalse\fi%
 \savebox{\this@label}{#1}\sticky@label\@gobblecr}
\long\def\L@dblarg#1{\@ifnextchar[{#1}{\L@xdblarg{#1}}}
\long\def\L@xdblarg#1#2{#1[]{#2}}
\long\def\addresslabel{\L@dblarg{\@addresslabel}}
\long\def\@addresslabel[#1]#2{\genericlabel{#1%
 \begin{tabular}{@{}p{\area@width}@{}}\raggedright #2\end{tabular}}}
\long\def\boxedaddresslabel{\L@dblarg{\@boxedaddresslabel}}
\long\def\@boxedaddresslabel[#1]#2{\genericlabel{#1%
 \addr@width=\area@width\advance\addr@width by-2\fboxsep%
 \advance\addr@width by-2\fboxrule\fbox{%
  \begin{tabular}{@{}p{\addr@width}@{}}\raggedright #2\end{tabular}}}}
\long\def\labels
 {\iffirst@label\LabelSetup\first@labelfalse\fi\start@@label}
\def\endlabels{\end@@label}
\def\start@@label{%
 \savebox{\this@label}\bgroup\raggedright%
 \begin{minipage}{\area@width}\raggedright%
 \catcode `\^^M =\active\@gobblecr%
}%
\def\end@@label{%
 \end{minipage}\egroup%
 \sticky@label}%
\def\start@newline{\mbox{}\expandafter\newline}%
\def\new@label{\end@@label\start@@label}%
\catcode `\^^M = \active%
\def ^^M{\futurelet\nexttoken\isitapar}%
\def\isitapar{\ifx^^M\nexttoken\let\action=\new@label\else%
 \let\action\start@newline\fi\action}%
\catcode `\^^M = 5\relax%
\def\labelfile#1{\begin{labels}\input#1\end{labels}}
\def\promptlabels{\typein[\labelfilename]{What is the name of the
 label file?}
 \labelfile{\labelfilename}}
\newcount\sk@pped
\def\skiplabels#1{\sk@pped=#1%
 \savebox{\this@label}{\rule{0pt}{.5in}}%
 \skip@labels=0\relax
 \loop\ifnum\skip@labels<\sk@pped\make@label%
 \advance\skip@labels by 1\relax\repeat}
\endinput
%%
%% End of file `olabels.sty'.
