% HMLaTeX2e 34567890123456789012345678901234567890123456789012345678901234567890
%-------------------------------------------------------------------------------
% Aanpassing van LaTeX2e inclusief enkele aanvullingen
\def\fileversion{1.4}
\def\filedate{1999/12/19}
\def\filename{cropmarks}
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{cropmarks}%
	[\filedate\space\fileversion\space Cropmarks and pageframes HvdM]
% 28-08-1995	updated for new outputcode, cropmarks hooked in at \@begindvi
% 19-12-1999	pageframe colored
%-------------------------------------------------------------------------------
%-------------------------------------------------------------------------------
\@ifundefined{pageheight}%
	{\newlength{\pageheight}\setlength{\pageheight}{\paperheight}}{}
\@ifundefined{pagewidth}%
	{\newlength{\pagewidth}\setlength{\pagewidth}{\paperwidth}}{}
\newif\if@cropmarks
\newif\if@pageframes
\newcommand*\showframeCOLOR{\ifx\color\undefined\else\color{cyan}\fi}
%-------------------------------------------------------------------------------
%-------------------------------------------------------------------------------
% pageframes and cropmarks
%-------------------------------------------------------------------------------
%-------------------------------------------------------------------------------
% Options passed to it: pageframes, cropmarks
%-------------------------------------------------------------------------------
%-------------------------------------------------------------------------------
\DeclareOption{marks}{\@cropmarkstrue}
\DeclareOption{nomarks}{\@cropmarksfalse}	% default
%-------------------------------------------------------------------------------
% \showpageframes catches the \@texttop hook
% beware of resetters (most notably \raggedbottom, letter.sty)
% therefore set at the latest moment possible: at \begin{document}-time.
\newcommand{\@pgftexttopswtch}{%
	\let\@@texttop=\@texttop
	\def\@texttop{\@showpageframes\@@texttop}%
	}
\DeclareOption{pageframe}{\@pageframestrue\AtBeginDocument{\@pgftexttopswtch}}
\@onlypreamble\@pgftexttopswtch
%-------------------------------------------------------------------------------
\newcommand\@showpageframes{%
	\vbox to\z@{\showframeCOLOR\offinterlineskip
		\hbox{\vrule\@height.4pt\@width\textwidth}\vskip-.4pt
		\hbox to\textwidth{%
			\vrule\@height\z@\@width.4pt\@depth\textheight
			\hfil
			\vrule\@height\z@\@width.4pt\@depth\textheight
			}%
		\hbox{\vrule\@height.4pt\@width\textwidth}\vskip-.4pt
		\vss}\nointerlineskip}
%-------------------------------------------------------------------------------
\DeclareOption*{\PackageError{\filename}{Unknown option `\CurrentOption'}}
\ProcessOptions
%-------------------------------------------------------------------------------
% setup with cropmarks centered on the papersize
\newcommand\@centercropmarks{%
	\@tempdima\paperheight
	\advance\@tempdima-\pageheight
	\divide\@tempdima\tw@
	\advance\@tempdima-1in
	\@tempdimb\paperwidth
	\advance\@tempdimb-\pagewidth
	\divide\@tempdimb\tw@
	\advance\@tempdimb-1in
	}
%-------------------------------------------------------------------------------
\newcommand\@showcropmarks{%
	\if@cropmarks
	\@centercropmarks
	\moveright\@tempdimb\vbox to\z@{%
		\offinterlineskip
		\vskip\@tempdima
		\hbox to\pagewidth{\@@@cropmark tl\hfil\@@@cropmark tr}%
		\if@pageframes
			\hbox{\vrule\@height.4pt\@width\pagewidth}\vskip-.4pt
			\hbox to\pagewidth{%
				\vrule\@height\z@\@width.4pt\@depth\pageheight
				\hfil
				\vrule\@height\z@\@width.4pt\@depth\pageheight
				}%
			\hbox{\vrule\@height.4pt\@width\pagewidth}\vskip-.4pt
		\else
			\vskip\pageheight
		\fi
		\hbox{\@@@cropmark bl\hskip\pagewidth\@@@cropmark br}%
		\vss}%
	\nointerlineskip
	\fi}
%
\def \@begindvi{%
  \@showcropmarks
  \unvbox \@begindvibox
  \gdef\@begindvi{\@showcropmarks}%
}
%-------------------------------------------------------------------------------
\newcommand\@@@cropmark[2]{%
	\csname#2lap\endcsname{%
		\vbox to\z@{\showframeCOLOR
			\if#1t\vss\else\hbox to.5in{%
				\if#2r\hfil\fi
				\vrule\@width.45in\@height.4pt\@depth\z@
				\if#2l\hfil\fi
				}%
			\vglue.05in\fi
			\hbox to.5in{%
				\if#2l\hfil\fi
				\vrule\@height.45in\@depth\z@
				\if#2r\hfil\fi
				}%
			\if#1b\vss\else\vglue.05in
				\hbox to.5in{%
					\if#2r\hfil\fi
					\vrule\@width.45in\@height.4pt\@depth\z@
					\if#2l\hfil\fi
					}%
			\fi
		}}}
%-------------------------------------------------------------------------------
\endinput
