summaryrefslogtreecommitdiff
path: root/macros/generic/cropmark/cropmark.sty
blob: f6bdada0fb62c750e582a1df3b22b9fb886e3e43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Cropmark.tex
% version 1.0
%
% This will put crop marks on everythings that's \shipout'ed.
% It will work with any format, since it relies on redefinition
% of \shipout. Exception: if you declare \output{} you will
% not get crop marks.
%
% Cut along the center of the rules to get exactly the shipped
% out box. To get padding around this box, use the parameters below.
%
% User adjustable parameters:
% \croplength    length of the crop rules
% \cropwidth     width of the crop rules
% \cropsep       separation between rule and page box
% \croppadtop    padding in case page box looks bigger than it is
% \croppadbot    (for instance with plain TeX head/footline)
% \croppadlr
%
% Date: 17 March 1992
%
% Author:
%    Victor Eijkhout
%    Department of Computer Science
%    University Tennessee at Knoxville
%    104 Ayres Hall
%    Knoxville, TN 37996
%    USA
%
%    eijkhout@cs.utk.edu
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% save the old \shipout command
\let\xshipout\shipout

% define a new one: investigate what's being shipped
\def\shipout{\futurelet\SomeBox\yshipout}

% if its a box register, do postprocessing with \afterassignment,
% otherwise do \afterassignment which will do \aftergroup
\def\yshipout
   {\ifx\SomeBox\box        \let\next\shipAfterRegister 
    \else \ifx\SomeBox\copy \let\next\shipAfterRegister
    \else                   \let\next\shipAfterBox \fi\fi
    \afterassignment\next\setbox0=
    }
\def\shipAfterBox{\aftergroup\shipAfterRegister}

% now we have whatever is being shipped in box0,
% so we can insert crop marks
\newdimen\croplength \croplength=20pt
\newdimen\cropsep \cropsep=10pt  
\newdimen\cropwidth \cropwidth=2pt

\newdimen\croppadtop \croppadtop=0pt
\newdimen\croppadbot \croppadbot=0pt
\newdimen\croppadlr  \croppadlr=0pt

\def\crophrule{\vrule height\cropwidth depth0pt width\croplength}
\def\cropvrule{\vrule width\cropwidth depth0pt height\croplength}

\def\shipAfterRegister
   {\setbox0\vbox
       {\offinterlineskip
        \dimen0\cropsep\advance\dimen0\croplength
        \setbox2\hbox to \wd0
               {\kern-\croppadlr\kern-.5\cropwidth
                \cropvrule\hfil\cropvrule
                \kern-.5\cropwidth\kern-\croppadlr}
        \setbox4\hbox to \wd0{\llap{\crophrule\kern\cropsep\kern\croppadlr}
                              \hfil
                              \rlap{\kern\croppadlr\kern\cropsep\crophrule}}
        % go a bit up, put vertical rules, put horizontal rules
        \kern-\dimen0
        \copy2
        \kern\cropsep\kern-.5\cropwidth
        \copy4
        \kern-.5\cropwidth
        % padding
        \kern\croppadtop
        % the box to be shipped
        \box0
        % padding
        \kern\croppadbot
        % and now the top in reverse
        \kern-.5\cropwidth
        \box4
        \kern-.5\cropwidth\kern\cropsep
        \box2
    }
    \xshipout\box0\relax}
\endinput