summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/misc/cropmrks.tex
blob: d3d065775bceed50c42ba7b19852c21226b6f9ce (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
%%% Usage:

%%% \input cropmarks
%%% \topcropmark = <dimen> [plus <dimen>] [minus <dimen>]
%%% \bottomcropmark = <dimen> [plus <dimen>] [minus <dimen>]
%%% \leftcropmark = <dimen> [plus <dimen>] [minus <dimen>]
%%% \rightcropmark = <dimen> [plus <dimen>] [minus <dimen>]
%%% \lrcropmarkstrue ;;; iff you want alternating left and right cropmarks only
%%% \rvcropmarkstrue ;;; iff you want recto and verso specified independently
%%%                     (in which case the first four variables are two-valued
%%%                      as \recto<var> and \verso<var>).

%%% Square brackets indicate optional items, and the <dimen>s are
%%% respectively (and all measured w.r.t. the origin, which is the
%%% top left corner of the notional, rather than physical page; the
%%% exact origin will need to be determined by inspection)

%%% 	The distance to the centre of the cross;
%%% 	The distance which the cross extends beyond the page limits;
%%% 	The distance which the cross extends within the page limits.

%%% Any or all can be zero <unit>s.  For conventional (exo-) cropmarks, the
%%% `plus' component indicates the length of the mark, and the `minus' component
%%% should be omitted or zero.  For inverted (endo-) cropmarks, the `plus'
%%% component should be omitted or zero, and the `minus' component indicates the
%%% length of the mark.  If `plus' or `minus' components are negative, this
%%% has the effect of a `white cropmark' extending in the reverse direction
%%% for the specified distance; this may be used to achieve non-touching marks.
%%% The first and only mandatory component may be also negative, to cope with
%%% pathological origins. 

%
%%% A test which will allow us to be read regardless of the \catcode of `@'
%

\newif \ifatletter
\ifcat @A\atlettertrue \else \catcode `\@ = 11 \atletterfalse \fi

\ifx \c@tcodeminus \undefined 
\else \message {Warning: previous meaning of \string \c@tcodeminus \space lost}
\fi
\edef \c@tcodeminus {\the \catcode `\-}
\catcode `\- = 12

%
\message {CROPMARKS.TEX V1.5 Copyright (C) 14-JUL-1994 14:52:34 Philip Taylor}
%

%
%%% Miscellaneous variables
%

\newif    \iflrcropmarks			\lrcropmarksfalse
\newif    \ifrvcropmarks         		\rvcropmarksfalse
\newdimen \cropmarkwidth			\cropmarkwidth = 0.4 pt
\newdimen \t@pshift
\newdimen \b@ttomshift
\newdimen \l@ftshift
\newskip  \topcropmark
\newskip  \leftcropmark
\newskip  \rightcropmark
\newskip  \bottomcropmark
\newskip  \rectotopcropmark
\newskip  \rectoleftcropmark
\newskip  \rectorightcropmark
\newskip  \rectobottomcropmark
\newskip  \versotopcropmark
\newskip  \versoleftcropmark
\newskip  \versorightcropmark
\newskip  \versobottomcropmark
\newskip  \m@rkskip
\newskip  \m@rkplus
\newskip  \m@rkminus
\newbox   \p@gebox
\newbox   \cr@pmarkbox
\newbox   \topcr@pmarkbox
\newbox   \bottomcr@pmarkbox
%
%%% Extraordinary arcanery, to parse <skip>s into <dimen>s; any better ways ?
%
\begingroup
\catcode `\P = 12 \catcode `\L = 12 \catcode `\U = 12 \catcode `\S = 12 
\catcode `\M = 12 \catcode `\I = 12 \catcode `\N = 12 \catcode `\T = 12 
\globaldefs = 1
\lowercase
{%
\def \p@rseskip #1%
	{\expandafter \p@rs@skip \the #1 PLUS 0.0PT MINUS 0.0PT \@ndparse #1 }
\def \p@rs@skip #1 PLUS #2 MINUS #3\@ndparse #4
	{%
	 \m@rkskip  = #1%
	 \m@rkplus  = #2%
	 \m@rkminus = #3%
	 \ifdim \m@rkminus = 0.0 pt
		\expandafter \p@rs@sk@p \the \m@rkskip MINUS 0.0PT \@ndparse
	 \fi
	}%
\def \p@rs@sk@p #1MINUS #2\@ndparse {\m@rkskip = #1 \m@rkminus = #2 }
}
\endgroup
%
%%% Take control of \shipout, to force it to add cropmarks
%
\let \ship@ut = \shipout
\def \shipout {\futurelet \b@x \whichb@x}
\def \whichb@x
 	{%
 	 \ifx 	\b@x \vbox
	 	\def \n@xt {\setbox \p@gebox = }%
 	      	\afterassignment \Shipout
 	 \else 	\ifx 	\b@x \hbox
 			\def \n@xt {\setbox \p@gebox = }%
 	 	     	\afterassignment \Shipout
	 	\else 	\ifx 	\b@x \box
	 			\def \n@xt {\setbox \p@gebox = }%
 	 		   	\afterassignment \Ship@ut
	 		\else	\ifx 	\b@x \copy
	 				\def \n@xt {\setbox \p@gebox = }%
 	 	 			\afterassignment \Ship@ut
	 			\else
	 				\def \n@xt {\ship@ut}%
	 	 			\message {Sorry, can't understand 
	 						what follows \shipout}%
	 			\fi
	 		\fi
	 	\fi
	 \fi
 	 \n@xt
	}
\def \Shipout {\aftergroup \Ship@ut}
\def \Ship@ut 
	{%
         \ifrvcropmarks
                \ifodd \pageno
                        \topcropmark = \rectotopcropmark
                        \bottomcropmark = \rectobottomcropmark
                        \leftcropmark = \rectoleftcropmark
                        \rightcropmark = \rectorightcropmark
                \else
                        \topcropmark = \versotopcropmark
                        \bottomcropmark = \versobottomcropmark
                        \leftcropmark = \versoleftcropmark
                        \rightcropmark = \versorightcropmark
                \fi
         \fi
         \hoffset = \leftcropmark
	 \setbox \topcr@pmarkbox = 
	 \hbox	 \bgroup
		 \p@rseskip \leftcropmark
 		 \iflrcropmarks
 		    \ifodd \count 0 
 			\let \next = \phantom 
 		    \else 
 			\let \next = \relax
 		    \fi 			 			
 		 \else 
 		    \let \next = \relax		    
  		 \fi
 		 \next {\ifdim  \m@rkminus < 0 pt
                                \begingroup
                                \advance \m@rkplus by \m@rkminus
 			        \vrule height \cropmarkwidth 
                                       depth 0 pt width \m@rkplus
                                \kern -\m@rkminus
                                \endgroup
                        \else
 			        \vrule height \cropmarkwidth 
                                        depth 0 pt width \m@rkplus
                        \fi
 			        \begingroup
 			        \p@rseskip \topcropmark
 			        \vrule	height \m@rkplus 
 				        depth \m@rkminus 
 				        width \cropmarkwidth
 			        \endgroup
                        \ifdim  \m@rkplus < 0 pt
                                \begingroup
                                \advance \m@rkminus by \m@rkplus
 			        \rlap {\kern -\m@rkplus
                                       \vrule height \cropmarkwidth 
 					      depth 0 pt width \m@rkminus}%
                                \endgroup
                        \else                                        
 			        \rlap {\vrule height \cropmarkwidth 
 					      depth 0 pt width \m@rkminus}%
                        \fi
 		       }%
		 \hskip \m@rkskip
		 \p@rseskip \rightcropmark
		 \hskip \m@rkskip
 		 \iflrcropmarks
 		    \ifodd \count 0 
 			\let \next = \relax
 		    \else 
 			\let \next = \phantom 
 		    \fi 			 			
 		 \else 
 		    \let \next = \relax		    
  		 \fi
 		 \next {\ifdim  \m@rkplus < 0 pt
                                \begingroup
                                \advance \m@rkminus by \m@rkplus
			        \llap {\vrule	height \cropmarkwidth 
 					depth 0 pt width \m@rkminus
                                        \kern -\m@rkplus
                                      }%
                                \endgroup
                        \else
			        \llap {\vrule	height \cropmarkwidth 
 					depth 0 pt width \m@rkminus
                                      }%
                        \fi
                                \begingroup
 				\p@rseskip \topcropmark
 				\vrule  height \m@rkplus 
 				        depth \m@rkminus 
 					width \cropmarkwidth
 				\endgroup
                        \ifdim  \m@rkminus < 0 pt
                                \begingroup
                                \advance \m@rkplus by \m@rkminus
                                \kern -\m@rkminus
 			        \vrule height \cropmarkwidth 
                                depth 0 pt width \m@rkplus
                                \endgroup
                        \else
 			        \vrule height \cropmarkwidth 
                                       depth 0 pt width \m@rkplus
                        \fi
 		       }%%%%%%%% end of parameter to \next
		 \egroup%%%%%%%% end of \bgroup ... \egroup to \setbox ...
	 \ht \topcr@pmarkbox = 0 pt
	 \dp \topcr@pmarkbox = 0 pt
	 \wd \topcr@pmarkbox = \wd \p@gebox
	 \setbox \bottomcr@pmarkbox = 
	 \hbox	 \bgroup
		 \p@rseskip \leftcropmark
 		 \iflrcropmarks
 		    \ifodd \count 0 
 			\let \next = \phantom 
 		    \else 
 			\let \next = \relax
 		    \fi 			 			
 		 \else 
 		    \let \next = \relax		    
  		 \fi
 		 \next {\ifdim  \m@rkminus < 0 pt
                                \begingroup
                                \advance \m@rkplus by \m@rkminus
 			        \vrule height \cropmarkwidth 
                                       depth 0 pt width \m@rkplus
                                \kern -\m@rkminus
                                \endgroup
                        \else
 			        \vrule height \cropmarkwidth 
                                        depth 0 pt width \m@rkplus
                        \fi
 			        \begingroup
 			        \p@rseskip \bottomcropmark
 			        \vrule	height \m@rkminus
 				        depth \m@rkplus
 				        width \cropmarkwidth
 			        \endgroup
                        \ifdim  \m@rkplus < 0 pt
                                \begingroup
                                \advance \m@rkminus by \m@rkplus
 			        \rlap {\kern -\m@rkplus
                                       \vrule height \cropmarkwidth 
 					      depth 0 pt width \m@rkminus}%
                                \endgroup
                        \else                                        
 			        \rlap {\vrule height \cropmarkwidth 
 					      depth 0 pt width \m@rkminus}%
                        \fi
 		       }%
		 \hskip \m@rkskip
		 \p@rseskip \rightcropmark
		 \hskip \m@rkskip
 		 \iflrcropmarks
 		    \ifodd \count 0 
 			\let \next = \relax
 		    \else 
 			\let \next = \phantom 
 		    \fi 			 			
 		 \else 
 		    \let \next = \relax		    
  		 \fi
 		 \next {\ifdim  \m@rkplus < 0 pt
                                \begingroup
                                \advance \m@rkminus by \m@rkplus
			        \llap {\vrule	height \cropmarkwidth 
 					depth 0 pt width \m@rkminus
                                        \kern -\m@rkplus
                                      }%
                                \endgroup
                        \else
			        \llap {\vrule	height \cropmarkwidth 
 					depth 0 pt width \m@rkminus
                                      }%
                        \fi
                                \begingroup
 				\p@rseskip \bottomcropmark
 				\vrule  height \m@rkminus
 				        depth \m@rkplus
 					width \cropmarkwidth
 				\endgroup
                        \ifdim  \m@rkminus < 0 pt
                                \begingroup
                                \advance \m@rkplus by \m@rkminus
                                \kern -\m@rkminus
 			        \vrule height \cropmarkwidth 
                                depth 0 pt width \m@rkplus
                                \endgroup
                        \else
 			        \vrule height \cropmarkwidth 
                                       depth 0 pt width \m@rkplus
                        \fi
 		       }%%%%%%%% end of parameter to \next
		 \egroup%%%%%%%% end of \bgroup ... \egroup to \setbox ...
	 \ht \bottomcr@pmarkbox = 0 pt
	 \dp \bottomcr@pmarkbox = 0 pt
	 \wd \bottomcr@pmarkbox = \wd \p@gebox
	 \setbox \cr@pmarkbox = \vbox
	 	\bgroup
		\offinterlineskip
	 	\p@rseskip \leftcropmark	\l@ftshift = \m@rkskip
		\advance \l@ftshift by \m@rkplus
		\advance \l@ftshift by \cropmarkwidth
	 	\p@rseskip \topcropmark		\t@pshift = \m@rkskip
	 	\p@rseskip \bottomcropmark	\b@ttomshift = \m@rkskip
 		\vskip -\t@pshift 
 			\moveleft \l@ftshift \box \topcr@pmarkbox
		\vskip +\t@pshift
 		\vskip +\b@ttomshift
 			\moveleft \l@ftshift \box \bottomcr@pmarkbox
 		\vskip -\b@ttomshift
	 	\egroup
	 \setbox \p@gebox = \vbox 
		{\offinterlineskip 
		 \box \cr@pmarkbox
		 \box \p@gebox}%
	 \ship@ut \box \p@gebox
	}
%
%%% Restore \catcode of `-' & `@'
%

\catcode `\- = \c@tcodeminus
\let \c@tcodeminus = \undefined
\ifatletter \else \catcode `\@ = 12 \fi

%%% All done