%% disklabel.sty
%% Author: Victor V. Wagner <vitus@ice.ru>
%% Author: Artem V. Chuprina <ran@lpcs.math.msu.ru>
%%
%% printing a labels for CD and Zip disk and cassette boxes
%% provides environments
%%
%% ziplabel --- for IOMEGA ZIP disks
%% cdlabel --- for CDs
%% cassettelabel --- for cassettes
%%
%% disklabelbackside, disklabeltwoside --- generic labels.
%%		Set lengths \coverwidth, \coverheight and \coverdepth
%%		appropriately before use.
%%
%% \begin{disklabelbackside}[backside label]{left-or-both-side label}
%% Main label paragraph
%% \end{disklabelbackside}
%% makes ----------------------------------------
%%       |       |   |                          |
%%       |       |   |  Main label paragraph    |
%%       |   B   | L |                          |
%%       |   S   | S |                          |
%%       |   L   | L |                          |
%%       |       |   |                          |
%%       |       |   |                          |
%%       ----------------------------------------
%% Where BSL is a anticlockwise-rotated backside or both-side label,
%% LSL is a anticlockwise-rotated left-or-both-side label.
%%
%% \begin{disklabeltwoside}[leftside label]{right-or-both-side label}
%% Main label paragraph
%% \end{disklabeltwoside}
%% makes ------------------------------------
%%       |   |                          |   |
%%       |   |  Main label paragraph    |   |
%%       | L |                          | R |
%%       | S |                          | S |
%%       | L |                          | L |
%%       |   |                          |   |
%%       |   |                          |   |
%%       ------------------------------------
%% Where LSL is a anticlockwise-rotated leftside or both-side label,
%% RSL is a anticlockwise-rotated right-or-both-side label.
%%
%% BSL, LSL and RSL are read in LR mode, so they should be hboxes or one-line
%% text. Main label paragraph is read in paragraph mode.
%%
%% Copyright (c) by Victor B. Wagner & Artem V. Chuprina 1998
%%
\def\fileversion{0.0}
\def\filedate{1998/10/04}
\ProvidesPackage{disklabel}[\filedate\space\fileversion\space Disk labelling]
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{rotating}

\newlength{\coverwidth}
\newlength{\coverheight}
\newlength{\coverdepth}
\newlength{\coverbackside}
\newlength{\labelpagewidth}
\newlength{\covermargin}
\setlength{\covermargin}{4mm}
%
% Page setup
%
\pagestyle{empty}
\oddsidemargin=-0.75in
\textwidth=210mm
\topmargin=-0.5in % Leave something for techical purposes
\headsep=0pt
\headheight=0pt
\textheight=290mm
%
\def\disklabelbackside{\@ifnextchar[{\diskl@belbacksidenonequ@l}{\diskl@belbacksideequ@l}}
\def\diskl@belbacksideequ@l#1{\diskl@belbackside{#1}{#1}}
\def\diskl@belbacksidenonequ@l[#1]{\diskl@belbackside{#1}}
\def\diskl@belbackside#1#2{%
    \labelpagewidth=\coverwidth%
    \advance\labelpagewidth by -2\covermargin%
    \vbox
    \bgroup
	\hrule
	\hbox
	\bgroup%
	    \vrule%
	    \hbox to \coverbackside
	    {%
		\hfil\sideways%
		\hbox to \coverheight{\hfil#1\hfil}%
		\endsideways\hfil%
	    }%
	    \vrule%
	    \hbox to \coverdepth
	    {%
		\hfil\sideways%
		\hbox to \coverheight{\hfil#2\hfil}%
		\endsideways\hfil%
	    }%
	    \vrule%
	    \hbox to \coverwidth
	    \bgroup%
		\hsize=\labelpagewidth%
		\hspace{\covermargin}%
		\vbox to \coverheight%
		\bgroup%
		    \vspace{\covermargin}
}
\def\enddisklabelbackside{
		    \vss
		\egroup%
		\hspace{\covermargin}%
	    \egroup%
	    \vrule%
	\egroup%
	\hrule
    \egroup
}

\def\disklabeltwoside{\@ifnextchar[{\diskl@beltwosidenonequ@l}{\diskl@beltwosideequ@l}}
\def\diskl@beltwosideequ@l#1{\diskl@beltwoside{#1}{#1}}
\def\diskl@beltwosidenonequ@l[#1]{\diskl@beltwoside{#1}}
\def\diskl@beltwoside#1#2{%
    \labelpagewidth=\coverwidth%
    \advance\labelpagewidth by -2\covermargin%
    \vbox
    \bgroup
	\hrule
	\hbox
	\bgroup%
	    \vrule%
	    \hbox to \coverdepth
	    {%
		\hfil\sideways%
		\hbox to \coverheight{\hfil#1\hfil}%
		\endsideways\hfil%
	    }%
	    \def\diskl@beltwoside@secondparameter{#2}%
	    \vrule%
	    \hbox to \coverwidth
	    \bgroup%
		\hsize=\labelpagewidth%
		\hspace{\covermargin}%
		\vbox to \coverheight%
		\bgroup%
		    \vspace{\covermargin}
}
\def\enddisklabeltwoside{
		    \vss
		\egroup%
		\hspace{\covermargin}%
	    \egroup%
	    \vrule%
	    \hbox to \coverdepth
	    {%
		\hfil\sideways%
		\hbox to \coverheight{\hfil\diskl@beltwoside@secondparameter\hfil}%
		\endsideways\hfil%
	    }%
	    \vrule%
	\egroup%
	\hrule
    \egroup
}

\def\ziplabel{%
    \setlength{\coverwidth}{96mm}%
    \setlength{\coverheight}{96mm}%
    \setlength{\coverdepth}{7mm}%
    \setlength{\coverbackside}{2cm}%
    \disklabelbackside%
}
\def\endziplabel{\enddisklabelbackside}

\def\cassettelabel{%
    \setlength{\coverwidth}{65mm}%
    \setlength{\coverheight}{100mm}%
    \setlength{\coverdepth}{13mm}%
    \setlength{\coverbackside}{20mm}%
    \disklabelbackside%
}
\def\endcassettelabel{\enddisklabelbackside}

\def\cdlabel{%
    \setlength{\coverwidth}{138mm}%
    \setlength{\coverheight}{117mm}%
    \setlength{\coverdepth}{6mm}%
    \setlength{\coverbackside}{0cm}%
    \disklabeltwoside%
}
\def\endcdlabel{\enddisklabeltwoside}
\endinput
