]> mj.ucw.cz Git - ucwmac.git/blob - ucw-labels.tex
ucw-ref: Fixed bug in \pageid
[ucwmac.git] / ucw-labels.tex
1 %% Macros for typesetting of labels
2
3 \ucwdefmodule{labels}
4
5 % Default page parameters. You can change them before calling \setuplabels.
6 \setmargins{0pt}
7 \setuppage
8
9 % Do we want rules around each label?
10 \newif\iflabelrules
11 \labelrulesfalse
12
13 % Do we want cropmarks?
14 \newif\iflabelcropmarks
15 \labelcropmarksfalse
16 \def\labelcropm{\iflabelcropmarks\hbox to 0pt{\hss\vbox to \labelh{\crosshair{5pt}\vss\crosshair{5pt}}}\fi}
17
18 % Margins of each label
19 \newdimen\labelhmargin
20 \labelhmargin=5mm
21
22 \newdimen\labelvmargin
23 \labelvmargin=5mm
24
25 % Internals
26 \newdimen\labelw
27 \newdimen\labelh
28 \newcount\labelnum
29
30 % Prepare of typesetting of #2 rows per #1 labels
31 \def\setuplabels#1#2{
32         \labelw=\hsize
33         \divide\labelw by #1
34         \labelh=\vsize
35         \divide\labelh by #2
36         \labelnum=#1
37         \multiply\labelnum by #2
38         \offinterlineskip
39         \parindent=0pt
40         \parskip=0pt
41         \rightskip=0pt plus 0.1pt
42 }
43
44 % Typeset one label as a box (in most cases, you want to use \label instead)
45 \long\def\labelbox#1{\hbox to \labelw{%
46   \labelcropm
47   \iflabelrules\vrule\fi
48   \hss
49   \vbox to \labelh{%
50     \iflabelrules\hrule\fi
51     \vss
52     \hbox to \labelw{%
53       \hss
54       \vbox to \labelh{%
55         \vss
56         \dimen0=\labelh
57         \advance\dimen0 by -2\labelvmargin
58         \vbox to \dimen0{%
59           \hsize=\labelw
60           \advance\hsize by -2\labelhmargin
61           \normalbaselines
62           #1
63           \hrule width \hsize height 0pt depth 0pt
64         }%
65         \vss
66       }%
67       \hss
68     }
69     \vss
70     \iflabelrules\hrule\fi
71   }%
72   \hss
73   \labelcropm
74   \iflabelrules\vrule\fi
75   }%
76 }
77
78 % Typeset one label (#1 is expected to have the exact height, so it usually ends with a \vfil)
79 \long\def\label#1{\leavevmode\labelbox{#1}\penalty -100}
80
81 % Typeset #1 copies of label #2
82 \newcount\labelcount
83 \long\def\labels#1#2{{\leavevmode\setbox0=\labelbox{#2}%
84   \labelcount=#1%
85   \loop
86     \copy0
87     \penalty -100
88     \advance\labelcount by -1
89   \ifnum\labelcount>0\repeat
90 }}
91
92 % Fill the whole page with copies of a label
93 \long\def\labelfill#1{\labels\labelnum{#1}}