\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ncccropmark}
         [2002/02/08 v1.01 Cropmarks (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
%
% \cropmark[hfm]{left skip}{right skip}{top skip}{bottom skip}{length}
%
% useful as a watermark. The command desired for use together with the
% watermark package. It must be called in the picture environment.
%
% The optional parameter contains a combination of letters h (header),
% f (footer), and m (marginal notes). It determines the additional fields
% of paper area taken into account when the cropmark is typed out. 
% If the optional parameter is omitted, the crop area coinsides with
% the text area.
%
% Skip parameters mean indentations of cropmark corners outside of the
% crop area and the last parameter is equal to crop lines length.
% Its positive value means cropmark corners looking on the crop area.
% In twoside mode left skip and right skip are swapped for every even page.
%
% For example \watermark{\cropmark[ht]{10mm}{10mm}{10mm}{10mm}{5mm}} means
% a crop mark indented on 10mm in all directions from the crop area
% containing the page header, text area, and footer.
%
\RequirePackage{ncccropbox}
\RequirePackage{tocenter}
%
% We consider the \cropmark to be used at the beginning of header.
%
\newcommand*{\cropmark}[6][]{\NCC@pos{#1}% see tocenter package
  %
  % Calculate cropbox width and left skip
  %
  \setlength{\@tempdima}{#2}% left skip
  \setlength{\@tempdimb}{#3}% right skip
  \@tempswafalse            % true means left margin
  \if@twoside \ifodd\c@page\else % reverse skips
    \@tempswatrue
    \setlength{\@tempdima}{#3}%
    \setlength{\@tempdimb}{#2}%
  \fi\fi
  \if@twocolumn  
    \NCC@m\@tempdima \NCC@m\@tempdimb
  \else
    \if@tempswa
      \if@reversemargin \NCC@m\@tempdimb \else \NCC@m\@tempdima \fi
    \else
      \if@reversemargin \NCC@m\@tempdima \else \NCC@m\@tempdimb \fi
    \fi
  \fi  
  \@tempskipa -\@tempdima      % left skip calculated
  \advance\@tempdima\@tempdimb
  \advance\@tempdima\textwidth % crop box width calculated
  %
  % Calculate cropbox height and bottom skip  
  %
  \@tempdimb\headsep
  \advance\@tempdimb\textheight
  \NCC@f\@tempdimb
  \addtolength{\@tempdimb}{#5}%
  \@tempskipb -\@tempdimb     % bottom skip calculated
  \advance\@tempdimb -\headsep
  \NCC@h\@tempdimb
  \addtolength{\@tempdimb}{#5}% crop box height calculated
  \begingroup
    \croplinelength{#6}%
    \lineskip\z@
    \@killglue\raise\@tempskipb
      \hb@xt@\z@{\kern\@tempskipa
        \cropbox[\@tempdima][\@tempdimb]{}\hss}\hss%
  \endgroup
}
\endinput
