\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ncccropbox}
         [2002/02/08 v1.03 Crop Box Package (NCC)]
%
% \changes{v1.02}{2002/01/31}{This version is uploaded to CTAN}
% \changes{v1.03}{2002/02/08}{The package is renamed to ncccropbox}
%
% The package implements the command
%
%   \cropbox[width][height]{contents}
%
% which prepares a box with crop marks at its corners looking like angles.
% The crop box is aligned at the bottom and is lowered at \lineskip value.
% If an optional parameter is empty or omitted, the total width
% (height) of the crop box is calculated from
% the width (height) of the contents plus 2\cropboxsep. The width of crop mark
% lines is equal to \croplinewidth{width}. The length of crop mark lines is
% controlled by the \croplinelength{length} command.
% If the length is negative then the angles will go outside the crop box.
% The defaults for \croplinewidth, \croplinelength, and \cropboxsep
% are 0.4pt, 10pt, and 5pt respectively.
%
\newcommand*{\croplinelength}[1]{\def\CRB@length{#1}}
\newcommand*{\croplinewidth}[1]{\def\CRB@width{#1}}
\newcommand*{\cropboxsep}[1]{\def\CRB@sep{#1}}
\newcommand*{\cropbox}[1][]{\@ifnextchar[{\CRB@box[#1]}{\CRB@box[#1][]}}
\def\CRB@box[#1][#2]#3{%
  \@begin@tempboxa\hbox{#3}%
    \def\@tempa{#1}\ifx\@tempa\@empty
      \@tempdima\width \advance\@tempdima 2\CRB@sep\relax
    \else
      \setlength\@tempdima{#1}%
    \fi
    \def\@tempa{#2}\ifx\@tempa\@empty
      \@tempdimb\totalheight \advance\@tempdimb 2\CRB@sep\relax
    \else
      \setlength\@tempdimb{#2}%
    \fi
    \setbox\z@\hb@xt@\z@{%
      \linethickness{\CRB@width}%
      \setlength\unitlength{\CRB@length}%
      \ifdim\unitlength=\z@ \else
        \ifdim\unitlength>\z@
          \CRB@hcross\z@\z@\@ne\@ne
          \CRB@hcross\@tempdima\z@\m@ne\@ne
          \CRB@hcross\z@\@tempdimb\@ne\m@ne
          \CRB@hcross\@tempdima\@tempdimb\m@ne\m@ne
        \else \unitlength -\unitlength
          \CRB@hcross\z@\z@\m@ne\m@ne
          \CRB@hcross\@tempdima\z@\@ne\m@ne
          \CRB@hcross\z@\@tempdimb\m@ne\@ne
          \CRB@hcross\@tempdima\@tempdimb\@ne\@ne
        \fi
      \fi
    }%
    \leavevmode \ht\z@\z@ \dp\z@\z@ \box\z@
    \advance\@tempdimb -\lineskip
    \vbox to\@tempdimb{\vss\vskip -\lineskip
      \hb@xt@\@tempdima{\hss\unhbox\@tempboxa\hss}\vss\kern\z@
    }%
  \@end@tempboxa
}
\def\CRB@hcross#1#2#3#4{%
  \@killglue\raise#2\hb@xt@\z@{\kern#1\line(#3,0)\@ne\hss}\hss
  \@killglue\raise#2\hb@xt@\z@{\kern#1\line(0,#4)\@ne\hss}\hss
}
% Initial settings
\croplinelength{10pt}
\croplinewidth{.4pt}
\cropboxsep{5pt}
\endinput
