pack-cut.mkxl /size: 5974 b    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=pack-cut, % comes from core-vis/trac-vis
3%D        version=1996.06.01,
4%D          title=\CONTEXT\ Packaging Macros,
5%D       subtitle=Cut boxes,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\unprotect
15
16%D When I am in the mood I will implement the main macro in a more modern way using
17%D offsets and such. Or maybe using \METAPOST\ instead
18%D
19%D \macros
20%D   {makecutbox, cuthbox, cutvbox, cutvtop}
21%D
22%D Although mainly used for marking the page, these macros can also serve local use.
23%D
24%D \startbuffer
25%D \setbox0=\vbox{a real \crlf vertical box} \makecutbox0
26%D \stopbuffer
27%D
28%D \typebuffer
29%D
30%D This marked \type{\vbox} shows up as:
31%D
32%D \startlinecorrection
33%D \getbuffer
34%D \stoplinecorrection
35%D
36%D The alternative macros are used as:
37%D
38%D \startbuffer
39%D \cuthbox{a made cut box}
40%D \stopbuffer
41%D
42%D \typebuffer
43%D
44%D This is typeset as:
45%D
46%D \startlinecorrection
47%D \getbuffer
48%D \stoplinecorrection
49%D
50%D By setting the next macros one can influence the length of the marks as well as
51%D the horizontal and vertical divisions.
52
53\newdimension\d_pack_cutmarks_width
54\newdimension\d_pack_cutmarks_height
55\newdimension\d_pack_cutmarks_depth
56
57\newinteger  \horizontalcutmarks   \horizontalcutmarks \plustwo
58\newinteger  \verticalcutmarks     \verticalcutmarks   \plustwo
59\newinteger  \cutmarkoffset        \cutmarkoffset      \plusone
60
61\mutable\let\cutmarksymbol       \relax
62\mutable\def\cutmarklength       {2\bodyfontsize}
63\mutable\def\cutmarkrulethickness{\onepoint}
64
65\mutable\lettonothing\cutmarktoptext
66\mutable\lettonothing\cutmarkbottomtext
67\mutable\lettonothing\cutmarkhoffset
68\mutable\lettonothing\cutmarkvoffset
69
70\permanent\protected\def\horizontalcuts
71  {\hpack to \d_pack_cutmarks_width
72     {\localcontrolledrepeat\horizontalcutmarks{\vrule\s!width\cutmarkrulethickness\s!height\cutmarklength\hfill}%
73      \unskip}}
74
75\permanent\protected\def\verticalcuts
76  {\vpack to \dimexpr\d_pack_cutmarks_height+\d_pack_cutmarks_depth\relax
77     {\hsize\cutmarklength
78      \localcontrolledrepeat\verticalcutmarks{\vrule\s!height\cutmarkrulethickness\s!width\hsize\vfill}%
79      \unskip}}
80
81\permanent\protected\def\baselinecuts
82  {\ifdim\d_pack_cutmarks_depth>\zeropoint
83     \vpack to \dimexpr\d_pack_cutmarks_height+\d_pack_cutmarks_depth\relax
84       {\hsize\dimexpr\cutmarklength/2\relax
85        \vskip\zeropoint\s!plus\d_pack_cutmarks_height
86        \vrule\s!height\cutmarkrulethickness\s!width\hsize
87        \vskip\zeropoint\s!plus\d_pack_cutmarks_depth}%
88   \fi}
89
90\permanent\protected\def\cutmarksymbols#1%
91  {\hpack to \d_pack_cutmarks_width
92     {\setbox\scratchbox\hbox to \cutmarklength
93        {\hss\infofont\cutmarksymbol\hss}%
94      \hss
95      \vpack to \cutmarklength
96        {\scratchdimen\dimexpr\cutmarklength/2\relax
97         \scratchdistance\ifempty\cutmarkhoffset\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi
98         \vss
99         \hbox to \d_pack_cutmarks_width
100           {\llap{\copy\scratchbox\kern\scratchdistance}%
101            \kern\scratchdimen\hss
102            \infofont#1%
103            \hss
104            \kern\scratchdimen
105            \rlap{\kern\scratchdistance\copy\scratchbox}}%
106         \vss}%
107      \hss}}
108
109\permanent\protected\def\makecutbox#1% not grouped !
110  {\d_pack_cutmarks_height\ht#1%
111   \d_pack_cutmarks_depth \dp#1%
112   \d_pack_cutmarks_width \wd#1%
113   \setbox#1\hpack
114     {\dontcomplain
115      \forgetall
116      \boxmaxdepth\maxdimen
117      \offinterlineskip
118      \scratchdimen\dimexpr\cutmarklength/2\relax
119      \hsize\d_pack_cutmarks_width
120      \setbox\scratchbox\vpack
121        {\setbox\scratchbox\hpack{\horizontalcuts}%
122         \scratchdistance\ifempty\cutmarkvoffset\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi
123         \tlap{\copy\scratchbox\vskip\scratchdistance}%
124         \hpack to \d_pack_cutmarks_width
125           {\scratchdistance\ifempty\cutmarkhoffset\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi
126            \setbox\scratchbox\hpack{\verticalcuts}%
127            \llap{\copy\scratchbox\kern\scratchdistance}%
128            \ifzeropt\d_pack_cutmarks_depth
129              \hfill
130            \else
131              \begingroup
132              \setbox\scratchbox\hpack{\baselinecuts}%
133              \llap{\copy\scratchbox\kern\scratchdistance}%
134              \hfill
135              \rlap{\kern\scratchdistance\copy\scratchbox}%
136              \endgroup
137            \fi
138            \rlap{\kern\scratchdistance\copy\scratchbox}}%
139         \blap{\vskip\scratchdistance\copy\scratchbox}}%
140      \ht\scratchbox\d_pack_cutmarks_height
141      \dp\scratchbox\d_pack_cutmarks_depth
142      \wd\scratchbox\zeropoint
143      \startcolor[\defaulttextcolor]%
144      \box\scratchbox
145      \ifrelax\cutmarksymbol \else
146        \setbox\scratchbox\vpack
147          {\scratchdistance\ifempty\cutmarkvoffset\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi
148           \vskip-\dimexpr\scratchdistance+\cutmarklength\relax
149           \hpack{\cutmarksymbols\cutmarktoptext}%
150           \vskip\dimexpr\scratchdistance+\d_pack_cutmarks_height+\d_pack_cutmarks_depth+\scratchdistance\relax
151           \hpack{\cutmarksymbols\cutmarkbottomtext}}%
152        \ht\scratchbox\d_pack_cutmarks_height
153        \dp\scratchbox\d_pack_cutmarks_depth
154        \wd\scratchbox\zeropoint
155        \box\scratchbox
156      \fi
157      \stopcolor
158      \box#1}%
159   \wd#1\d_pack_cutmarks_width
160   \ht#1\d_pack_cutmarks_height
161   \dp#1\d_pack_cutmarks_depth
162   \box#1}
163
164\permanent\protected\def\cuthbox{\hpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\hbox}
165\permanent\protected\def\cutvbox{\vpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\vbox}
166\permanent\protected\def\cutvtop{\tpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\vtop}
167
168\protect \endinput
169