| 1 |
% \iffalse |
| 2 |
% |
| 3 |
%% File: labels.dtx |
| 4 |
%% Originally copyright (C) 1993-1994-1995-1998 by Sebastian Rahtz |
| 5 |
%% and Grant Gustafson |
| 6 |
%% Copyright (C) 2002-2003 by Julian Gilbey <[email protected]> |
| 7 |
% |
| 8 |
% This program may be distributed and/or modified under the |
| 9 |
% conditions of the LaTeX Project Public License, either version 1.2 |
| 10 |
% of this license or (at your option) any later version. |
| 11 |
% The latest version of this license is in |
| 12 |
% http://www.latex-project.org/lppl.txt |
| 13 |
% and version 1.2 or later is part of all distributions of LaTeX |
| 14 |
% version 1999/12/01 or later. |
| 15 |
% |
| 16 |
% This program consists of the files labels.dtx and labels.ins |
| 17 |
% together with the generated files labels.sty and olabels.sty. |
| 18 |
% |
| 19 |
\NeedsTeXFormat{LaTeX2e} |
| 20 |
%<*dtx> |
| 21 |
\ProvidesFile{labels.dtx}[2003/05/22 v.13] |
| 22 |
%</dtx> |
| 23 |
% The version number also appears in the package code below. |
| 24 |
%<*driver> |
| 25 |
\documentclass{ltxdoc} |
| 26 |
\ProvidesFile{labels.drv}[2003/05/22 v.13] |
| 27 |
\GetFileInfo{labels.drv} |
| 28 |
\begin{document} |
| 29 |
\title{A package for making sticky labels in \LaTeX\thanks{This file |
| 30 |
has version number \fileversion, last revised \filedate.}} |
| 31 |
\author{Sebastian Rahtz, Leonor Barroca \and Grant Gustafson \and |
| 32 |
Julian Gilbey} |
| 33 |
\date{2003/05/22} |
| 34 |
\maketitle |
| 35 |
\tableofcontents |
| 36 |
\DocInput{labels.dtx} |
| 37 |
\end{document} |
| 38 |
%</driver> |
| 39 |
% \fi |
| 40 |
% \CheckSum{732} |
| 41 |
% \begin{abstract} |
| 42 |
% A \LaTeX\ style to print |
| 43 |
% a regular grid of ragged-right labels on a page, suitable for sheets |
| 44 |
% of labels |
| 45 |
% which can be fed through a laser printer. Macros are provided to |
| 46 |
% allow easy input of names and addresses in a form free of \TeX\ markup. |
| 47 |
% Equally useful is a feature for making multiple copies of a single |
| 48 |
% label, e.g., return address stickers to go with the labels. |
| 49 |
% \end{abstract} |
| 50 |
% |
| 51 |
% \section{Generating Style Files and Documentation} |
| 52 |
% Automatic generation of the style files uses the command line |
| 53 |
% \begin{center} |latex labels.ins| \end{center} |
| 54 |
% to create the files |labels.sty| (for \LaTeX{}2e) |
| 55 |
% and |olabels.sty| (for \LaTeX{}209). Usage in the preamble section of |
| 56 |
% a \LaTeX{} source file is |
| 57 |
% |\input{olabels.sty}| for \LaTeX{}209 and |
| 58 |
% |\usepackage{labels}| for \LaTeX{}2e. Backward compatibility with |
| 59 |
% \LaTeX{}209 may be removed suddenly in some future release. Please |
| 60 |
% observe that documentation is created by the command line |
| 61 |
% |latex labels.dtx|, |
| 62 |
% and no provision is made to produce documentation via \LaTeX{}209. |
| 63 |
% |
| 64 |
% \section{Usage} |
| 65 |
% This style file was written to produce a sheet of labels which can be |
| 66 |
% xeroxed onto \textsf{Avery brand} 5360 sticky-label material. This label |
| 67 |
% material is made for a xerox machine and it has 7 rows and 3 |
| 68 |
% columns of labels on |letterpaper|. It works for other label |
| 69 |
% layouts as well. In particular, the defaults for the most popular |
| 70 |
% paper sizes |letterpaper| and |a4paper| are $7$ |
| 71 |
% rows by $3$ columns and $8$ rows by $3$ columns, respectively. |
| 72 |
% |
| 73 |
% Other uses include production of disk labels, book labels, shipping |
| 74 |
% labels, name tags, door cards, photo galleries and compact membership |
| 75 |
% lists. |
| 76 |
% |
| 77 |
% The task of this package is to produce a rectangular grid of |
| 78 |
% items on a sheet of paper, with each item centered in its grid area. |
| 79 |
% It really doesn't matter what goes in the grid area: text, graphics or |
| 80 |
% any \LaTeX{} construct. For example, you might use the |fancybox| |
| 81 |
% package to produce oval-box or shadow-box name tags for a conference. |
| 82 |
% |
| 83 |
% \subsection{Paper Sizes} |
| 84 |
% The paper size is supplied by the document options for the class. |
| 85 |
% The European default is |a4paper| and the American default is |
| 86 |
% |letterpaper|, $8.5\times 11$-inch, inherited from the |
| 87 |
% class file, e.g., |article.cls|. |
| 88 |
% \begin{description} |
| 89 |
%\item[\textbf{a4paper}] 297mm by 210mm. |
| 90 |
%\item[\textbf{a5paper}] 210mm by 148mm. |
| 91 |
%\item[\textbf{b5paper}] 250mm by 176mm. |
| 92 |
%\item[\textbf{letterpaper}] 11in by 8.5in. |
| 93 |
%\item[\textbf{legalpaper}] 14in by 8.5in. |
| 94 |
%\item[\textbf{executivepaper}] 10.5in by 7.25in. |
| 95 |
%\end{description} |
| 96 |
% |
| 97 |
% \subsection{Label Stock Sizes} |
| 98 |
% A number of different label stocks are available for xerox machines |
| 99 |
% and laser printers. The typical stock has $m$ rows and $n$ columns |
| 100 |
% with various gutters on the page. Below is a table of \textsf{Avery} |
| 101 |
% products that are in common use in America. |
| 102 |
% |
| 103 |
% \medskip |
| 104 |
% |
| 105 |
%\DeleteShortVerb{\|} |
| 106 |
%{\small\rm |
| 107 |
%\begin{tabular}{|c|c|c|c|c|l|} |
| 108 |
%\hline |
| 109 |
%Label Size & Labels & Rows & Cols & Gutters &Avery \\ |
| 110 |
%in inches & per page & & & & Stock No \\ \hline |
| 111 |
%$1\frac{7}{16}\times2\frac{13}{16}$ & 21/page & 7 & 3 & Yes & 5360 \\ \hline |
| 112 |
%$2\times4\frac14$ & 10/page & 5 & 2 & Yes & 5352 \\ \hline |
| 113 |
%$2\times4$ & 10/page & 5 & 2 & Yes & 5327 \\ \hline |
| 114 |
%$1\times4$ & 20/page & 10 & 2 & Yes & 5161, 5261 \\ \hline |
| 115 |
%$1\frac{3}{8}\times2\frac{11}{16}$ & 21/page & 7 & 3 & Yes & 5329 \\ \hline |
| 116 |
%$1\times2\frac{5}{8}$ & 30/page & 10 & 3 & Yes & 5331, 5160, 5260 \\ \hline |
| 117 |
%$1\frac{1}{3}\times4$ & 14/page & 7 & 2 & Yes & 5162, 5262 \\ \hline |
| 118 |
%$\frac{1}{2}\times1\frac{3}{4}$ & 80/page & 20 & 4 & Yes & 5267 \\ \hline |
| 119 |
%$1\times2\frac34$ & 33/page & 11 & 3 & No & 5332, 5351, 5354, 5314 \\ \hline |
| 120 |
%\end{tabular} |
| 121 |
%} |
| 122 |
%\MakeShortVerb{\|} |
| 123 |
% |
| 124 |
% \medskip |
| 125 |
% |
| 126 |
% Another common label stock is \textsf{Dennison} 37-141, having 3 columns |
| 127 |
% and 8 rows of $1\frac38\times2\frac78$ gutterless labels on |
| 128 |
% letterpaper. The information by the manufacturer is not precisely |
| 129 |
% correct, because the first column \emph{is} exactly $2\frac78$ inches |
| 130 |
% wide, but the other two are $2\frac{13}{16}$ inches wide. |
| 131 |
% |
| 132 |
% A common problem with implementing this package on a new label stock |
| 133 |
% is precision of the laser printer, which prints the master, and the |
| 134 |
% xerox machine which prints the master onto the label stock. Some of |
| 135 |
% the above are for direct use on a laser printer, which removes one |
| 136 |
% source of error, but replaces it by the possibility that the label |
| 137 |
% stock will jam in the laser printer! |
| 138 |
% |
| 139 |
% \subsection{Customizing for Other Labels: the traditional method} |
| 140 |
% It is very likely that the label stock will be different than Avery 5360. |
| 141 |
% Generally, it is necessary to tailor the source file to a particular type |
| 142 |
% of label. |
| 143 |
% The lines below may be placed in the preamble and edited to suit |
| 144 |
% the application and the actual printer used for output. |
| 145 |
% \begin{verbatim} |
| 146 |
% \documentclass[12pt]{article} |
| 147 |
% \usepackage{labels} |
| 148 |
% \LabelCols=3% Number of columns of labels per page |
| 149 |
% \LabelRows=7% Number of rows of labels per page |
| 150 |
% \LeftBorder=8mm% Space added to left border of each label |
| 151 |
% \RightBorder=8mm% Space added to right border of each label |
| 152 |
% \TopBorder=9mm% Space to leave at top of sheet |
| 153 |
% \BottomBorder=2mm% Space to leave at bottom of sheet |
| 154 |
% \begin{document}% End of preamble |
| 155 |
% \end{verbatim} |
| 156 |
% These controls can also be issued after the beginning of the document, |
| 157 |
% but the results are undefined unless the following example is |
| 158 |
% followed, which uses the |\LabelSetup| control sequence: |
| 159 |
% \begin{verbatim} |
| 160 |
% \begin{document}% End of preamble |
| 161 |
% \LabelCols=3% Number of columns of labels per page |
| 162 |
% \LabelRows=7% Number of rows of labels per page |
| 163 |
% \LeftBorder=8mm% Space added to left border of each label |
| 164 |
% \RightBorder=8mm% Space added to right border of each label |
| 165 |
% \TopBorder=9mm% Space to leave at top of sheet |
| 166 |
% \BottomBorder=2mm% Space to leave at bottom of sheet |
| 167 |
% \LabelSetup% Invoke new settings |
| 168 |
% \end{verbatim} |
| 169 |
% For example, \emph{your} |
| 170 |
% grid maybe has only two columns of ten labels each, requiring the |
| 171 |
% first two variables to be reset. The gutter areas on the label |
| 172 |
% material dictate how to set the other parameters. |
| 173 |
% Personal adjustments can be made for the amount of white space around |
| 174 |
% each label. |
| 175 |
% |
| 176 |
% The printer driver is expected to print the page |
| 177 |
% \emph{exactly} as it should in vanilla \TeX, i.e., with the origin of |
| 178 |
% the page down one inch and right one inch from the top left hand |
| 179 |
% corner of the paper. If it doesn't, adjust the printer driver |
| 180 |
% parameters. |
| 181 |
% |
| 182 |
% A common problem with printers is that label output is |
| 183 |
% extra wide, requiring printing onto the very edges of the |
| 184 |
% paper. Some printers may not be able to maintain print quality |
| 185 |
% all the way to the edges of the paper. |
| 186 |
% Adjust the parameters |\LeftBorder|, |\RightBorder|, |\TopBorder|, |
| 187 |
% |\BottomBorder| as outlined below to solve this problem. |
| 188 |
% |
| 189 |
% First of all, |\TopBorder| is not the white space at the top of the |
| 190 |
% page, but the amount of space to leave at the top so that the first |
| 191 |
% label is centered on its grid. This number is determined by trial and |
| 192 |
% error using the actual printer, xerox machine and label stock to be |
| 193 |
% used in the production run. |
| 194 |
% |
| 195 |
% The second value |\BottomBorder| is determine empirically also, so |
| 196 |
% that the labels are all centered on their grids. A mathematical |
| 197 |
% formula to be satisfied is |
| 198 |
%\def\AA{\mbox{\texttt{paperheight}} - \mbox{\texttt{TopBorder}} - |
| 199 |
% \mbox{\texttt{BottomBorder}}} |
| 200 |
%\def\BB{\mbox{\texttt{LabelRows}}} |
| 201 |
%$$ \mbox{\texttt{Label Height}} = \frac{\AA}{\BB} $$ |
| 202 |
% The values |\LeftBorder| and |\RightBorder| are amounts of white space |
| 203 |
% to be added to the left and right of the actual label area so that the |
| 204 |
% label itself does not smash into the edge of the grid. The actual |
| 205 |
% label width is considerably smaller than the grid width (physical |
| 206 |
% width of the label stock). It is determined by the formula |
| 207 |
%\def\AA{\mbox{\texttt{paperwidth}}} |
| 208 |
%\def\BB{\mbox{\texttt{LabelCols}}} |
| 209 |
%\def\CC{\mbox{\texttt{LeftBorder}}} |
| 210 |
%\def\DD{\mbox{\texttt{RightBorder}}} |
| 211 |
%$$ \CC + \mbox{\texttt{Label Width}} + \DD = \frac{\AA}{\BB}$$ |
| 212 |
% Normally, the left and right white space dimensions are the same, but |
| 213 |
% there can be exceptions. It is best to determine the dimensions |
| 214 |
% empirically on the actual equipment to be used in the production run. |
| 215 |
% Visual guides from a |dvi| viewer can help, but be aware that the |
| 216 |
% laser printer may fail to print near the edge and the xerox machine |
| 217 |
% may either enlarge or shrink the image onto the label stock. |
| 218 |
% |
| 219 |
% An optional \textit{grid overlay} can be produced with the label output for |
| 220 |
% testing purposes by the preamble control sequence |\LabelInfotrue|. |
| 221 |
% Most |dvi| viewers are capable of showing the entire test grid. Once |
| 222 |
% printed, the overlay can be compared with the actual label stock to |
| 223 |
% see if the borders are in the proper place. By adjusting parameters, |
| 224 |
% the master copy off the laser printer should be able to pass through the |
| 225 |
% xerox machine automatically. |
| 226 |
% |
| 227 |
% \subsection{Customizing for Other Labels: the new method} |
| 228 |
% |
| 229 |
% One of the deficiencies of the method described above it that it is |
| 230 |
% unable to cope well with labels having spaces between them, and the |
| 231 |
% dimensions specified are not the natural ones which one would want |
| 232 |
% to measure. If the package option |newdimens| is given (and this |
| 233 |
% only works for users of \LaTeXe), then we can |
| 234 |
% give page parameters in a far more flexible manner as follows, where |
| 235 |
% these dimensions are suitable for Avery L7160 labels: |
| 236 |
% \begin{verbatim} |
| 237 |
% \documentclass[a4paper,12pt]{article} |
| 238 |
% \usepackage[newdimens]{labels} |
| 239 |
% \LabelCols=3% Number of columns of labels per page |
| 240 |
% \LabelRows=7% Number of rows of labels per page |
| 241 |
% \LeftPageMargin=7mm% These four parameters give the |
| 242 |
% \RightPageMargin=7mm% page gutter sizes. The outer edges of |
| 243 |
% \TopPageMargin=15mm% the outer labels are the specified |
| 244 |
% \BottomPageMargin=15mm% distances from the edge of the paper. |
| 245 |
% \InterLabelColumn=2mm% Gap between columns of labels |
| 246 |
% \InterLabelRow=0mm% Gap between rows of labels |
| 247 |
% \LeftLabelBorder=5mm% These four parameters give the extra |
| 248 |
% \RightLabelBorder=5mm% space used around the text on each |
| 249 |
% \TopLabelBorder=5mm% actual label. |
| 250 |
% \BottomLabelBorder=5mm% |
| 251 |
% \begin{document}% End of preamble |
| 252 |
% \end{verbatim} |
| 253 |
% (The |\LabelSetup| form can also be used, as above.) Thus the four |
| 254 |
% |\...PageMargin| parameters and the |\InterLabel...| paramenters |
| 255 |
% define the location of the physical labels on the page, and the |
| 256 |
% four |\...LabelBorder| parameters define how the space on each label |
| 257 |
% is to be used. |
| 258 |
% |
| 259 |
% As before, the printer driver is expected to print the page |
| 260 |
% \emph{exactly} as it should in vanilla \TeX, i.e., with the origin of |
| 261 |
% the page down one inch and right one inch from the top left hand |
| 262 |
% corner of the paper. If it doesn't, adjust the printer driver |
| 263 |
% parameters. |
| 264 |
% |
| 265 |
% We now describe how the locations of the labels are determined, as |
| 266 |
% we did before. The label height and label width are given by the |
| 267 |
% formul\ae: |
| 268 |
% $$\begin{array}{l} |
| 269 |
% \mbox{\texttt{LabelRows}}\times\mbox{\texttt{Label height}} + |
| 270 |
% (\mbox{\texttt{LabelRows}}-1)\times\mbox{\texttt{InterLabelRow}} =\\ |
| 271 |
% \qquad\mbox{\texttt{paperheight}} - \mbox{\texttt{TopPageMargin}} - |
| 272 |
% \mbox{\texttt{BottomPageMargin}} |
| 273 |
% \end{array}$$ |
| 274 |
% and |
| 275 |
% $$\begin{array}{l} |
| 276 |
% \mbox{\texttt{LabelColumns}}\times\mbox{\texttt{Label width}} + |
| 277 |
% (\mbox{\texttt{LabelColumns}}-1)\times\mbox{\texttt{InterLabelColumn}} =\\ |
| 278 |
% \mbox{\texttt{paperwidth}} - \mbox{\texttt{LeftPageMargin}} - |
| 279 |
% \mbox{\texttt{RightPageMargin}} |
| 280 |
% \end{array}$$ |
| 281 |
% Then, within each label, the label text is vertically centered in a |
| 282 |
% box which is indented |\TopLabelBorder| from the top of the label, |
| 283 |
% |\BottomLabelBorder| from the bottom, |\LeftLabelBorder| from the |
| 284 |
% left and |\RightLabelBorder| from the right. |
| 285 |
% |
| 286 |
% It is an error if $\mbox{\texttt{TopLabelBorder}} + |
| 287 |
% \mbox{\texttt{BottomLabelBorder}} \geq \mbox{\texttt{Label |
| 288 |
% height}}$, and similarly for the width; the results in such cases |
| 289 |
% may be unpredictable. |
| 290 |
% |
| 291 |
% Note that the |\LabelInfoTrue| function only draws the outlines of |
| 292 |
% the physical labels; see below for information on |\LabelGridtrue|. |
| 293 |
% |
| 294 |
% \subsection{Using an External Label source File} |
| 295 |
% The simplest form of input is very |
| 296 |
% short, as in the following example: |
| 297 |
% \begin{verbatim} |
| 298 |
% \documentclass{article} |
| 299 |
% \usepackage{labels} |
| 300 |
% \begin{document} |
| 301 |
% \labelfile{names.dat} |
| 302 |
% \end{document} |
| 303 |
% \end{verbatim} |
| 304 |
% where |names.dat| contains names and address in |
| 305 |
% \textit{plain format}. Source files in plain format may contain |
| 306 |
% extra blank lines (only one blank line between labels is required). |
| 307 |
% Sort fields should begin with |%| in column $1$, so they don't print |
| 308 |
% as part of the label. Leading and trailing blanks on lines are |
| 309 |
% ignored. The formfeed character Ctrl-L seems to be acceptable in the |
| 310 |
% source. A formfeed is not |
| 311 |
% ignored, even if it appears at the end of the file. For example, if |
| 312 |
% |^L| appears on a line by itself, then it either produces an empty |
| 313 |
% label or else a blank line, if it happens to be in a group of label |
| 314 |
% lines. The label data commonly appears on lines, flush left, with no |
| 315 |
% intervening blank lines, because a blank line signals a new label. To |
| 316 |
% purposely create blank labels, as for filling out a page of labels, |
| 317 |
% see the control sequence |\skiplabels{#1}|, \textit{infra}. The actual |
| 318 |
% text in the external file may contain \LaTeX{} markup controls. This |
| 319 |
% includes comment marks |%|, which will be ignored during typesetting. |
| 320 |
% |
| 321 |
%\section*{Source File Creation and Sorting} |
| 322 |
% Most mailing lists that already exist can be edited to create an |
| 323 |
% acceptable list in the proper format. If long lines are to wrap, |
| 324 |
% then force all the material to be wrapped onto one line in the source. |
| 325 |
% Otherwise, break the material into lines of the length desired. |
| 326 |
% Any special items in a mailing label can be coded in \LaTeX{}, e.g., |
| 327 |
% foreign names with accented characters, trademarks and font size |
| 328 |
% changes. |
| 329 |
% |
| 330 |
% Generally, raw sources have to be searched for special \LaTeX{} |
| 331 |
% controls and brought up to standard. The characters below may be |
| 332 |
% used in a source file for writing \LaTeX{} code. Generally, a raw |
| 333 |
% source has to be manually stripped of these characters. |
| 334 |
%\begin{verbatim} |
| 335 |
%Double quote \" Hash (number) \# Underscore \_ |
| 336 |
%Dollar \$ Percent \% Ampersand \& |
| 337 |
%Less than \< Greater than \> Vertical bar \| |
| 338 |
%Commercial at \@ Backslash \\ Circumflex \^ |
| 339 |
%Left brace \{ Right brace \} Tilde \~ |
| 340 |
%\end{verbatim} |
| 341 |
% |
| 342 |
% A typical comment line might start with |%| and then |^L| (ctrl-L) |
| 343 |
% followed by a sort key (e.g., the zip code or last name). The |emacs| |
| 344 |
% editor supports a method of sorting such records, thereby rearranging |
| 345 |
% the source file into a new label order. The method: |
| 346 |
% \begin{itemize} |
| 347 |
% \item |
| 348 |
% Mark the whole file as a region: |^[<| goes to the top of file, then |
| 349 |
% |^@| sets mark; follow by |^[>| to mark the whole file. |
| 350 |
%\item |
| 351 |
% Invoke |emacs|'s |sort-pages| external routine as follows. Press |^[x| |
| 352 |
% then enter |sort-pages| and press return. The region marked will be |
| 353 |
% sorted on the first line of each page, with a page delimited by |^L|. |
| 354 |
% For some |emacs| versions, the first line of the marked block has to |
| 355 |
% be empty, in order to produce a successful sort. |
| 356 |
% \end{itemize} |
| 357 |
% |
| 358 |
% \section*{General purpose \LaTeX{} Source} |
| 359 |
% |
| 360 |
% To set up a general-purpose \LaTeX{} source file, use |
| 361 |
% the following source, which prompts for the labels file name. |
| 362 |
% \begin{verbatim} |
| 363 |
% \documentclass{article} |
| 364 |
% \usepackage{labels} |
| 365 |
% \begin{document} |
| 366 |
% \promptlabels |
| 367 |
% \end{document} |
| 368 |
% \end{verbatim} |
| 369 |
% |
| 370 |
% \subsection{Labels in the Main File} |
| 371 |
% The names and addresses can appear directly in the main |
| 372 |
% file, rather than using \verb|\labelfile| to include them. |
| 373 |
% The file format is to be exactly as described above. Especially, |
| 374 |
% follow the advice about blank lines, which delimit labels. |
| 375 |
% This example makes use of the |labels| environment. |
| 376 |
% \begin{verbatim} |
| 377 |
% \documentclass{article} |
| 378 |
% \usepackage{labels} |
| 379 |
% \begin{document} |
| 380 |
% \begin{labels} |
| 381 |
% Me |
| 382 |
% My address |
| 383 |
% My City, State, Zipcode |
| 384 |
% |
| 385 |
% My Brother |
| 386 |
% His address |
| 387 |
% His City, State, Zipcode |
| 388 |
% \end{labels} |
| 389 |
% \end{document} |
| 390 |
% \end{verbatim} |
| 391 |
% |
| 392 |
% \subsection{Control Sequences to Make Labels} |
| 393 |
% There are other ways of accessing the same system. |
| 394 |
% \begin{enumerate} |
| 395 |
% \item The control sequence called |\addresslabel[#1]{#2}| accepts for |
| 396 |
% optional argument |#1| \LaTeX{} controls, e.g., font size and style, |
| 397 |
% and for argument |#2| the rows of a |tabular| array of one column. |
| 398 |
% \begin{verbatim} |
| 399 |
% \documentclass{article} |
| 400 |
% \usepackage{labels} |
| 401 |
% \begin{document} |
| 402 |
% \addresslabel[\small\sffamily] |
| 403 |
% {Me \\my street \\ mytown \\ England} |
| 404 |
% \end{document} |
| 405 |
% \end{verbatim} |
| 406 |
% |
| 407 |
% \item Boxed labels use the special macro called |
| 408 |
% |\boxedaddresslabel[#1]{#2}|, |
| 409 |
% as follows. This produces a frame-box around the label itself, leaving |
| 410 |
% lots of white space around the frame. An optional argument |[#1]| |
| 411 |
% is provided for local setting of \LaTeX{} controls, for example, |
| 412 |
% |[\fboxsep=3pt]| will change the white space near the frame. The |
| 413 |
% boolean variable |
| 414 |
% |\LabelInfotrue| appears in the preamble in order to print out |
| 415 |
% additional information, especially the label dimensions and the |
| 416 |
% settings of certain variables. |
| 417 |
% \begin{verbatim} |
| 418 |
% \documentclass{article} |
| 419 |
% \usepackage{labels} |
| 420 |
% \LabelInfotrue |
| 421 |
% \begin{document} |
| 422 |
% \boxedaddresslabel[\fboxsep=3pt] |
| 423 |
% {\textbf{Me} \\my street \\ mytown \\ England} |
| 424 |
% \end{document} |
| 425 |
% \end{verbatim} |
| 426 |
% |
| 427 |
% \item To \emph{duplicate} a label, there is a counter called |
| 428 |
% \verb|\numberoflabels| which you can set. |
| 429 |
% For example, to print a return address 21 times, use this |
| 430 |
% source: |
| 431 |
% \begin{verbatim} |
| 432 |
% \documentclass{article} |
| 433 |
% \usepackage{labels} |
| 434 |
% \numberoflabels=21 |
| 435 |
% \begin{document} |
| 436 |
% \addresslabel{Me \\my street \\ mytown \\ England} |
| 437 |
% \end{document} |
| 438 |
% \end{verbatim} |
| 439 |
% |
| 440 |
% \item For more sophisticated users, there is a macro |
| 441 |
% \verb|\genericlabel| which you can call, |
| 442 |
% with an argument of whatever you want to appear on the label (e.g., |
| 443 |
% for disk labels). Thus you could have |
| 444 |
% |
| 445 |
% \begin{tabular}{lp{1.0in}l} |
| 446 |
% \begin{minipage}{1.65in} |
| 447 |
% \begin{verbatim} |
| 448 |
% \genericlabel{% |
| 449 |
% \begin{tabular}{|c|} |
| 450 |
% \hline |
| 451 |
% My Amazing Program\\ |
| 452 |
% \hline |
| 453 |
% Disk 1 of 1\\ |
| 454 |
% \hline |
| 455 |
% \emph{We aim to serve}\\ |
| 456 |
% \hline |
| 457 |
% \end{tabular} |
| 458 |
% } |
| 459 |
% \end{verbatim} |
| 460 |
% \end{minipage} |
| 461 |
% & |
| 462 |
% \raggedright\sffamily |
| 463 |
% to produce a label like this: |
| 464 |
% & |
| 465 |
% \begin{minipage}{1.4in} |
| 466 |
% \begin{verbatim} |
| 467 |
% |------------------| |
| 468 |
% |My Amazing Program| |
| 469 |
% |------------------| |
| 470 |
% |Disk 1 of 1 | |
| 471 |
% |------------------| |
| 472 |
% |We aim to serve | |
| 473 |
% |------------------| |
| 474 |
% \end{verbatim} |
| 475 |
% \end{minipage} |
| 476 |
% \end{tabular} |
| 477 |
% \end{enumerate} |
| 478 |
% This feature has been used to print business cards with graphical |
| 479 |
% logo. |
| 480 |
% |
| 481 |
% \subsection{Wrapping Long Lines and Debugging} |
| 482 |
% Debugging of label files can be assisted by the internal error |
| 483 |
% messages which are emitted when a label box is too high or too wide |
| 484 |
% for the set parameters. This kind of error is unlikely to occur with |
| 485 |
% the standard controls and the \texttt{labels} environment, because by |
| 486 |
% default they use ragged right and wrap long lines. |
| 487 |
% |
| 488 |
% In all modes, you can opt for a grid around each label field by |
| 489 |
% setting a Boolean variable called |\LabelGridtrue|, e.g., |
| 490 |
% \begin{verbatim} |
| 491 |
% \documentclass{article} |
| 492 |
% \usepackage{labels} |
| 493 |
% \LabelGridtrue |
| 494 |
% \numberoflabels=21 |
| 495 |
% \begin{document} |
| 496 |
% \addresslabel{Me \\my street \\ mytown \\ England} |
| 497 |
% \end{document} |
| 498 |
% \end{verbatim} |
| 499 |
% By default you get no grids. The grids are useful for judging the |
| 500 |
% `spillover' of addresses onto adjacent labels, caused by long lines. |
| 501 |
% See also |\boxedaddresslabel|, which draws a tighter box with more |
| 502 |
% white space around the label text. Both can be used at the same time. |
| 503 |
% |
| 504 |
% \StopEventually{} |
| 505 |
% \section{The macros} |
| 506 |
% First of all, identify the package start, and specify that we |
| 507 |
% recognise the |newdimens| option. The |\iflabel@traddimens| macro |
| 508 |
% will record whether we are using the tradition |labels| dimension |
| 509 |
% system or not. |
| 510 |
% |
| 511 |
% \begin{macrocode} |
| 512 |
%<*package> |
| 513 |
%<!latex209>\NeedsTeXFormat{LaTeX2e} |
| 514 |
%<!latex209>\ProvidesPackage{labels}[2003/05/22 v.13] |
| 515 |
%<*latex209> |
| 516 |
\newdimen\paperwidth |
| 517 |
\paperwidth=8.5in% 297mm for a4paper |
| 518 |
\newdimen\paperheight |
| 519 |
\paperheight=11in% 210mm for a4paper |
| 520 |
\def\settoheight#1#2{\setbox\@tempboxa% |
| 521 |
\hbox{#2}#1\ht\@tempboxa\setbox\@tempboxa\box\voidb@x} |
| 522 |
\def\PackageWarning#1#2{\typeout{#1: #2}} |
| 523 |
%</latex209> |
| 524 |
\newif\iflabel@traddimens |
| 525 |
\label@traddimenstrue |
| 526 |
%<!latex209>\DeclareOption{newdimens}{\label@traddimensfalse} |
| 527 |
%<!latex209>\ProcessOptions |
| 528 |
% \end{macrocode} |
| 529 |
% We will be recording the size of a label, and the dimensions of the |
| 530 |
% grid, so we set up variables accordingly. |
| 531 |
% \begin{macrocode} |
| 532 |
\newcount\LabelCols |
| 533 |
\newcount\LabelRows |
| 534 |
\iflabel@traddimens |
| 535 |
\newdimen\LeftBorder |
| 536 |
\newdimen\RightBorder |
| 537 |
\newdimen\TopBorder |
| 538 |
\newdimen\BottomBorder |
| 539 |
\else |
| 540 |
\newdimen\LeftPageMargin |
| 541 |
\newdimen\RightPageMargin |
| 542 |
\newdimen\TopPageMargin |
| 543 |
\newdimen\BottomPageMargin |
| 544 |
\newdimen\InterLabelColumn |
| 545 |
\newdimen\InterLabelRow |
| 546 |
\newdimen\LeftLabelBorder |
| 547 |
\newdimen\RightLabelBorder |
| 548 |
\newdimen\TopLabelBorder |
| 549 |
\newdimen\BottomLabelBorder |
| 550 |
\fi |
| 551 |
\newcount\numberoflabels |
| 552 |
\newdimen\label@width |
| 553 |
\newdimen\label@height |
| 554 |
\newdimen\area@width |
| 555 |
\newdimen\area@height |
| 556 |
\newdimen\half@label |
| 557 |
\newdimen\half@area |
| 558 |
\newdimen\addr@width |
| 559 |
\newdimen\LabTmp |
| 560 |
\newsavebox\this@label |
| 561 |
\newcount\label@number |
| 562 |
\newcount\skip@labels |
| 563 |
\newcount\l@so@far |
| 564 |
\newcount\LabelTotal |
| 565 |
\newif\ifLabelGrid |
| 566 |
\newif\iffirst@label |
| 567 |
\newif\ifLabelInfo |
| 568 |
\first@labeltrue |
| 569 |
\LabelGridfalse |
| 570 |
\LabelInfofalse |
| 571 |
% \end{macrocode} |
| 572 |
% Set defaults for the labels based upon paper size and common use. |
| 573 |
% These values can be reset dynamically at runtime in the preamble. |
| 574 |
% \begin{macrocode} |
| 575 |
\ifdim\paperwidth=210mm\relax% |
| 576 |
\LabelCols=3\relax\LabelRows=8\relax% a4paper |
| 577 |
\else |
| 578 |
\LabelCols=3\relax\LabelRows=7\relax% letterpaper |
| 579 |
\fi% |
| 580 |
% \end{macrocode} |
| 581 |
% These variables are provided to allow you to force a border on the left |
| 582 |
% and right edges of each label. The values will affect every label, |
| 583 |
% of course, so you may need to experiment to get pleasing results. |
| 584 |
% The other variables adjust the gutter width at the top and bottom of a |
| 585 |
% page. They apply just to these two edges, and do not apply to a |
| 586 |
% particular label. Different defaults are necessary if we are using |
| 587 |
% |newdimens|. |
| 588 |
% A LaserJetIII seems to ignore about 8mm on the edges. Xerox machines |
| 589 |
% ignore even more, on all sides. |
| 590 |
% \begin{macrocode} |
| 591 |
\iflabel@traddimens |
| 592 |
\LeftBorder=8mm |
| 593 |
\RightBorder=8mm |
| 594 |
\TopBorder=9mm |
| 595 |
\BottomBorder=2mm |
| 596 |
\else |
| 597 |
\LeftPageMargin=4mm |
| 598 |
\RightPageMargin=4mm |
| 599 |
\TopPageMargin=5mm |
| 600 |
\BottomPageMargin=5mm |
| 601 |
\InterLabelColumn=0mm |
| 602 |
\InterLabelRow=0mm |
| 603 |
\LeftLabelBorder=5mm |
| 604 |
\RightLabelBorder=5mm |
| 605 |
\TopLabelBorder=4mm |
| 606 |
\BottomLabelBorder=4mm |
| 607 |
\fi |
| 608 |
% \end{macrocode} |
| 609 |
% We need to reset all the dimensions appropriately for a page of labels, |
| 610 |
% and the printer will need to know about the paper size as well. |
| 611 |
% \begin{macrocode} |
| 612 |
\textwidth=\paperwidth |
| 613 |
\textheight=\paperheight |
| 614 |
\topmargin=-1in |
| 615 |
\headheight=0em |
| 616 |
\headsep=0em |
| 617 |
\topskip=0em |
| 618 |
\footskip=0em |
| 619 |
\oddsidemargin=-1in |
| 620 |
\evensidemargin=-1in |
| 621 |
\pagestyle{empty} |
| 622 |
\parindent=0em |
| 623 |
\parskip=0pt |
| 624 |
% \end{macrocode} |
| 625 |
% Now calculate the size of labels simply as a proportion of the page |
| 626 |
% size (if you haven't got that right, this won't work, will it?). |
| 627 |
% This macro is to be executed before the first label is made. In |
| 628 |
% environment |labels| and macro |\genericlabel| (see below) this |
| 629 |
% happens automatically. If you write your own label environment or |
| 630 |
% macro, then model it after one of the aforementioned. |
| 631 |
% |
| 632 |
% We have two versions of this macro, depending on whether the |
| 633 |
% |newdimens| option has been set. |
| 634 |
% \begin{macrocode} |
| 635 |
\iflabel@traddimens |
| 636 |
\def\@LabelSetup{% |
| 637 |
\global\label@width\textwidth |
| 638 |
\global\divide\label@width by\LabelCols |
| 639 |
\global\label@height\textheight |
| 640 |
\global\advance\label@height by-\TopBorder |
| 641 |
\global\advance\label@height by-\BottomBorder |
| 642 |
\global\divide\label@height by\LabelRows |
| 643 |
% \end{macrocode} |
| 644 |
% The top margin of the paper is generally unused for |
| 645 |
% labels. \textsf{Avery} 5360 |
| 646 |
% label sheets have a $1/4$-inch gutter on the top and bottom. However, |
| 647 |
% there are no left or right margin gutters. We adjust the top margin to |
| 648 |
% keep the labels from printing on the gutter. |
| 649 |
% \begin{macrocode} |
| 650 |
\global\topmargin=-1in\global\advance\topmargin by\TopBorder |
| 651 |
% \end{macrocode} |
| 652 |
% It is not usually advisable to make the label printing go right to |
| 653 |
% the edge of the available area, so |\area@width| gives |
| 654 |
% the area that will actually be used for printing; the width is |
| 655 |
% cut down by |\LeftBorder| plus |\RightBorder|. These dimensions can be |
| 656 |
% set to zero if you have a design that uses the whole label. |
| 657 |
% \begin{macrocode} |
| 658 |
\global\area@width=\label@width |
| 659 |
\global\advance\area@width by -\LeftBorder |
| 660 |
\global\advance\area@width by -\RightBorder |
| 661 |
% \end{macrocode} |
| 662 |
% If the labels are to be produced on a grid, for debugging, then the |
| 663 |
% usual setting of |\fbox| separator width and |\fbox| rule width must |
| 664 |
% be subtracted so that the label box doesn't crash into the grid. |
| 665 |
% \begin{macrocode} |
| 666 |
\ifLabelGrid% |
| 667 |
\global\advance\area@width by-2\fboxsep |
| 668 |
\global\advance\area@width by-2\fboxrule |
| 669 |
\fi |
| 670 |
% \end{macrocode} |
| 671 |
% The height of the label box will be |2\half@label|. However, this box |
| 672 |
% will definitely crash into the grid lines. Reduce the label |
| 673 |
% height to account for the rule and separator widths that will be added |
| 674 |
% automatically by the boxing routine later on. |
| 675 |
% \begin{macrocode} |
| 676 |
\ifLabelGrid |
| 677 |
\global\advance\label@height by-2\fboxsep |
| 678 |
\global\advance\label@height by-2\fboxrule |
| 679 |
\fi |
| 680 |
\global\half@label=\label@height\divide\half@label by2\relax |
| 681 |
\global\label@number=1\relax |
| 682 |
} |
| 683 |
% \end{macrocode} |
| 684 |
% Now we handle the |newdimens| variant. The same general scheme |
| 685 |
% applies, but the calculations are different. |
| 686 |
% \begin{macrocode} |
| 687 |
\else |
| 688 |
\def\@LabelSetup{% |
| 689 |
\global\label@width\textwidth |
| 690 |
\global\advance\label@width by-\LeftPageMargin |
| 691 |
\global\advance\label@width by-\RightPageMargin |
| 692 |
\global\advance\label@width by-\LabelCols\InterLabelColumn |
| 693 |
\global\advance\label@width by\InterLabelColumn |
| 694 |
\global\divide\label@width by\LabelCols |
| 695 |
\ifdim\label@width<0pt |
| 696 |
\PackageWarning{labels}{Some dimensions are silly: label width |
| 697 |
\the\label@width~is negative!} |
| 698 |
\label@width=0pt |
| 699 |
\fi |
| 700 |
\global\label@height\textheight |
| 701 |
\global\advance\label@height by-\TopPageMargin |
| 702 |
\global\advance\label@height by-\BottomPageMargin |
| 703 |
\global\advance\label@height by-\LabelRows\InterLabelRow |
| 704 |
\global\advance\label@height by\InterLabelRow |
| 705 |
\global\divide\label@height by\LabelRows |
| 706 |
\ifdim\label@height<0pt |
| 707 |
\PackageWarning{labels}{Some dimensions are silly: label height |
| 708 |
\the\label@height~is negative!} |
| 709 |
\label@height=0pt |
| 710 |
\fi |
| 711 |
% \end{macrocode} |
| 712 |
% We now adjust the |\...margin| parameters to take account of |
| 713 |
% |\TopPageMargin| and |\LeftPageMargin|. |
| 714 |
% \begin{macrocode} |
| 715 |
\global\topmargin=-1in\global\advance\topmargin by\TopPageMargin |
| 716 |
\global\oddsidemargin=-1in\global\advance\oddsidemargin by\LeftPageMargin |
| 717 |
\global\evensidemargin=\oddsidemargin |
| 718 |
% \end{macrocode} |
| 719 |
% Again, |\area@width| gives the area that will actually be used for |
| 720 |
% printing; the width is cut down by |\LeftLabelBorder| plus |
| 721 |
% |\RightLabelBorder|. These dimensions can be set to zero if you |
| 722 |
% have a design that uses the whole label. Similarly, |\area@height| |
| 723 |
% gives the height of the printing area, |\half@label| gives half of |
| 724 |
% the label height and |\half@area| gives half of the printable area |
| 725 |
% height. |
| 726 |
% \begin{macrocode} |
| 727 |
\global\area@width=\label@width |
| 728 |
\global\advance\area@width by -\LeftLabelBorder |
| 729 |
\global\advance\area@width by -\RightLabelBorder |
| 730 |
\global\area@height=\label@height |
| 731 |
\global\advance\area@height by -\TopLabelBorder |
| 732 |
\global\advance\area@height by -\BottomLabelBorder |
| 733 |
\global\half@label=\label@height\divide\half@label by 2\relax |
| 734 |
\global\half@area=\area@height\divide\half@area by 2\relax |
| 735 |
\global\label@number=1\relax |
| 736 |
} |
| 737 |
\fi |
| 738 |
% \end{macrocode} |
| 739 |
% The boolean variable |\LabelInfotrue| is used to toggle the amount |
| 740 |
% of information printed at runtime. The boolean is placed in the |
| 741 |
% preamble to invoke a more informative printout. The default is no |
| 742 |
% information, but still echo a message, saying how to print more |
| 743 |
% information. |
| 744 |
% \begin{macrocode} |
| 745 |
\def\LabelSetup{\@LabelSetup |
| 746 |
\ifLabelInfo |
| 747 |
\typeout{Control sequences adjustable in the preamble:} |
| 748 |
\typeout{\LabelRows=\the\LabelRows} |
| 749 |
\typeout{\LabelCols=\the\LabelCols} |
| 750 |
\iflabel@traddimens |
| 751 |
\typeout{The newdimens option was not selected; the used parameters are:} |
| 752 |
\TypeoutBlurb{\TopBorder}{\TopBorder} |
| 753 |
\TypeoutBlurb{\BottomBorder}{\BottomBorder} |
| 754 |
\TypeoutBlurb{\LeftBorder}{\LeftBorder} |
| 755 |
\TypeoutBlurb{\RightBorder}{\RightBorder} |
| 756 |
\else |
| 757 |
\typeout{The newdimens option was selected; the used parameters are:} |
| 758 |
\TypeoutBlurb{\TopPageMargin}{\TopPageMargin} |
| 759 |
\TypeoutBlurb{\BottomPageMargin}{\BottomPageMargin} |
| 760 |
\TypeoutBlurb{\LeftPageMargin}{\LeftPageMargin} |
| 761 |
\TypeoutBlurb{\RightPageMargin}{\RightPageMargin} |
| 762 |
\TypeoutBlurb{\InterLabelColumn}{\InterLabelColumn} |
| 763 |
\TypeoutBlurb{\InterLabelRow}{\InterLabelRow} |
| 764 |
\TypeoutBlurb{\TopLabelBorder}{\TopLabelBorder} |
| 765 |
\TypeoutBlurb{\BottomLabelBorder}{\BottomLabelBorder} |
| 766 |
\TypeoutBlurb{\LeftLabelBorder}{\LeftLabelBorder} |
| 767 |
\TypeoutBlurb{\RightLabelBorder}{\RightLabelBorder} |
| 768 |
\fi |
| 769 |
\typeout{Computed values:} |
| 770 |
\TypeoutBlurb{Label Width}{\label@width} |
| 771 |
\TypeoutBlurb{Label Height}{\label@height} |
| 772 |
\else |
| 773 |
\typeout{To print info, put `\protect\LabelInfotrue' in the preamble} |
| 774 |
\fi |
| 775 |
} |
| 776 |
% \end{macrocode} |
| 777 |
% |
| 778 |
% We might want to print the same label several times, |
| 779 |
% so \verb|\sticky@label| will repeat \verb|\make@label| a |
| 780 |
% specified number of times (\verb|\numberoflabels|) |
| 781 |
% \begin{macrocode} |
| 782 |
\numberoflabels=1% |
| 783 |
% \end{macrocode} |
| 784 |
% |
| 785 |
% \begin{macrocode} |
| 786 |
\def\sticky@label{\l@so@far=0% |
| 787 |
\loop\ifnum\l@so@far<\numberoflabels\advance\l@so@far by 1\make@label% |
| 788 |
\repeat} |
| 789 |
% \end{macrocode} |
| 790 |
% |
| 791 |
% The real label-making macro appears below. |
| 792 |
% It assumes the actual text is in a box called \verb|\this@label|. |
| 793 |
% It is vital to make sure spaces are not included at the end of lines in |
| 794 |
% these macros, or all hell breaks loose. Internal checks are made for |
| 795 |
% box width and height, to report violations. The environments and |
| 796 |
% macros provided below always produce a ragged right box of fixed |
| 797 |
% width. Use |\genericlabel| to defeat the ragged right box and fixed |
| 798 |
% box width. |
| 799 |
% |
| 800 |
% \begin{macrocode} |
| 801 |
\def\make@label{% |
| 802 |
\ifnum\LabelTotal=0\vfill\eject\LabelTotal=\LabelRows\relax |
| 803 |
\multiply\LabelTotal by \LabelCols\fi |
| 804 |
\advance\LabelTotal by -1\relax |
| 805 |
\ifLabelGrid |
| 806 |
\let\boxing@type\framebox |
| 807 |
\else |
| 808 |
\let\boxing@type\makebox |
| 809 |
\fi |
| 810 |
% \end{macrocode} |
| 811 |
% The boxes made by the method below can overflow horizontally or |
| 812 |
% vertically. The code below emits an error message which pinpoints the |
| 813 |
% trouble and the degree of difficulty encountered. Most of the time |
| 814 |
% the text wrapping and ragged right controls fix the problem, but some |
| 815 |
% extra long lines can be troublesome. An essential part of this code is |
| 816 |
% to test the box for zero width, which will emit an empty label. If we |
| 817 |
% are doing it on purpose, then emit the label, otherwise discard it. |
| 818 |
% \begin{macrocode} |
| 819 |
\settowidth{\LabTmp}{\usebox{\this@label}}% |
| 820 |
\ifdim\LabTmp=0cm\let\action=\relax\else\let\action=\BuildB@x\fi |
| 821 |
%\TypeoutBlurb{Box Width}{\LabTmp}% |
| 822 |
\advance\LabTmp by -\area@width |
| 823 |
\ifdim\LabTmp>0cm\relax |
| 824 |
\PkgBlurb{Label too wide}{\LabTmp}\fi |
| 825 |
\settoheight{\LabTmp}% |
| 826 |
{\begin{tabular}{l}\usebox{\this@label}\end{tabular}}% |
| 827 |
%\TypeoutBlurb{Box height}{\LabTmp}% |
| 828 |
\iflabel@traddimens\advance\LabTmp by -\half@label |
| 829 |
\else\advance\LabTmp by -\half@area\fi |
| 830 |
\ifdim\LabTmp>0cm\relax |
| 831 |
\LabTmp=2\LabTmp\PkgBlurb{Label too tall}{\LabTmp}\fi |
| 832 |
% \end{macrocode} |
| 833 |
% Check for an empty box. Build the box provided it has some |
| 834 |
% dimension or else we are skipping labels on purpose. Otherwise, it's |
| 835 |
% empty and we discard it. |
| 836 |
% \begin{macrocode} |
| 837 |
\ifnum\skip@labels<\sk@pped\let\action=\BuildB@x\fi |
| 838 |
\action |
| 839 |
} |
| 840 |
% \end{macrocode} |
| 841 |
% Now build the box for the actual label. The box has minimum |
| 842 |
% height, which is set by using a vertical rule of zero width. At the |
| 843 |
% same time, set a minimum box width. |
| 844 |
% Set a position to half-way up a strut of the height of the label, |
| 845 |
% thus forcing text to be the correct height and vertically centered. |
| 846 |
% Apply box methods to adjust the white space left and right, using |
| 847 |
% horizontal rules of zero height. |
| 848 |
% \begin{macrocode} |
| 849 |
\def\BuildB@x{% |
| 850 |
\iflabel@traddimens |
| 851 |
\boxing@type[\label@width][c]{% |
| 852 |
\rule{0pt}{\label@height}% |
| 853 |
\raisebox{\half@label}[0pt][0pt]{% |
| 854 |
\rule{\LeftBorder}{0pt}% |
| 855 |
\usebox{\this@label}% |
| 856 |
\rule{\RightBorder}{0pt}% |
| 857 |
}}% |
| 858 |
% \end{macrocode} |
| 859 |
% We have a slightly different system when we are using the new |
| 860 |
% dimension system. We vertically center the label in the printing |
| 861 |
% area and indent in by the value of |\LeftLabelBorder|. We also mess |
| 862 |
% with the value of |\fboxsep| to make a framed box which doesn't |
| 863 |
% interfere with the placing of the label text. |
| 864 |
% \begin{macrocode} |
| 865 |
\else |
| 866 |
\begingroup |
| 867 |
\fboxsep=-\fboxrule |
| 868 |
\boxing@type{% |
| 869 |
\vbox to \label@height{% |
| 870 |
\vskip\TopLabelBorder |
| 871 |
\vss |
| 872 |
\hbox to \label@width{% |
| 873 |
\hskip\LeftLabelBorder |
| 874 |
\usebox{\this@label}% |
| 875 |
\hss |
| 876 |
}% |
| 877 |
\vss |
| 878 |
\vskip\BottomLabelBorder |
| 879 |
}% |
| 880 |
}% |
| 881 |
\endgroup |
| 882 |
\fi |
| 883 |
% \end{macrocode} |
| 884 |
% |
| 885 |
% Print |+| for this label to target errors by label number. |
| 886 |
% Empty labels made on purpose are printed as |x|. |
| 887 |
% Start a new line and print \verb"|" if we have printed a row |
| 888 |
% of |\LabelCols| labels. |
| 889 |
% \begin{macrocode} |
| 890 |
\ifnum\skip@labels<\sk@pped\message{x}\else\message{+}\fi |
| 891 |
\ifnum\label@number=\LabelCols |
| 892 |
\message{|}% |
| 893 |
\endgraf\nointerlineskip |
| 894 |
\iflabel@traddimens\else\vskip\InterLabelRow\fi |
| 895 |
\global\label@number=1 |
| 896 |
\else\global\advance\label@number by 1 |
| 897 |
\iflabel@traddimens\else\hskip\InterLabelColumn\fi |
| 898 |
\fi |
| 899 |
} |
| 900 |
% \end{macrocode} |
| 901 |
% To print out dimensions in more usual millimeters, |
| 902 |
% the following macros are used, which convert from \TeX's scaled points |
| 903 |
% into millimeters. The common \TeX{} points are also printed. |
| 904 |
% \begin{macrocode} |
| 905 |
\newcount\@Milli |
| 906 |
\def\ToMilli#1{\@Milli=#1\advance\@Milli by93225\relax |
| 907 |
\divide\@Milli by 186450\relax} |
| 908 |
\def\PkgBlurb#1#2{\ToMilli{#2}% |
| 909 |
\PackageWarning{labels}{#1 by \the\@Milli mm (\the #2)}% |
| 910 |
} |
| 911 |
\def\TypeoutBlurb#1#2{\ToMilli{#2}% |
| 912 |
\typeout{#1=\the\@Milli mm (\the #2)}% |
| 913 |
} |
| 914 |
% \end{macrocode} |
| 915 |
% |
| 916 |
% \section{User macros} |
| 917 |
% The basic case is a generic macro |\genericlabel{#1}| which takes its |
| 918 |
% argument |#1| and puts it out on a label. No ragged right. No fixed |
| 919 |
% width. Very basic. |
| 920 |
% \begin{macrocode} |
| 921 |
\newcommand{\genericlabel}[1]{% |
| 922 |
\iffirst@label\LabelSetup\first@labelfalse\fi% |
| 923 |
\savebox{\this@label}{#1}\sticky@label\@gobblecr} |
| 924 |
% \end{macrocode} |
| 925 |
% The more useful macro |\addresslabel[#1]{#2}| is based upon a tabular |
| 926 |
% environment, therefore it accepts lines ending in \verb"\\". It is |
| 927 |
% supposed to reproduce what is made by the |labels| environment. Extra |
| 928 |
% space left and right is removed from the tabular environment and the |
| 929 |
% width is fixed at value |\area@width| (see above for a discussion of |
| 930 |
% this computed dimension) with ragged right edge. The optional argument |
| 931 |
% |[#1]| is provided in order to set local values of certain variables, |
| 932 |
% for example, |[\fboxrule=2pt]| could appear as the optional argument |
| 933 |
% in order to locally change box rule size, without affecting the grid |
| 934 |
% line size used for debugging. |
| 935 |
% The plan is to use the common denominator of 2.09 and 2e, so |
| 936 |
% first we define some double argument double-talk. |
| 937 |
% \begin{macrocode} |
| 938 |
\long\def\L@dblarg#1{\@ifnextchar[{#1}{\L@xdblarg{#1}}} |
| 939 |
\long\def\L@xdblarg#1#2{#1[]{#2}} |
| 940 |
% \end{macrocode} |
| 941 |
% Using \LaTeX{2e} extensions, the command |\addresslabel[#1]{#2}| could |
| 942 |
% be coded as |\newcommand{\addresslabel}[2][]{...}|. |
| 943 |
% In coding common to both 2.09 and 2e, the following works: |
| 944 |
% \begin{macrocode} |
| 945 |
\long\def\addresslabel{\L@dblarg{\@addresslabel}} |
| 946 |
\long\def\@addresslabel[#1]#2{\genericlabel{#1% |
| 947 |
\begin{tabular}{@{}p{\area@width}@{}}\raggedright #2\end{tabular}}} |
| 948 |
% \end{macrocode} |
| 949 |
% The macro |\boxedaddresslabel[#1]{#2}| adds a framed box around the |
| 950 |
% address label defined above. The trouble here is in determining the |
| 951 |
% box width, which is reduced from its normal size by the widths of the |
| 952 |
% box rule and rule separator. The optional argument |[#1]| is the same |
| 953 |
% as for the previous macro, but here it performs a real service, |
| 954 |
% because it is often the case that box rule and box separator sizes |
| 955 |
% should be adjusted locally. |
| 956 |
% \begin{macrocode} |
| 957 |
\long\def\boxedaddresslabel{\L@dblarg{\@boxedaddresslabel}} |
| 958 |
\long\def\@boxedaddresslabel[#1]#2{\genericlabel{#1% |
| 959 |
\addr@width=\area@width\advance\addr@width by-2\fboxsep% |
| 960 |
\advance\addr@width by-2\fboxrule\fbox{% |
| 961 |
\begin{tabular}{@{}p{\addr@width}@{}}\raggedright #2\end{tabular}}}} |
| 962 |
% \end{macrocode} |
| 963 |
% The environment |labels|, for verbatim labels, will be defined. |
| 964 |
% \begin{macrocode} |
| 965 |
\long\def\labels |
| 966 |
{\iffirst@label\LabelSetup\first@labelfalse\fi\start@@label} |
| 967 |
\def\endlabels{\end@@label} |
| 968 |
% \end{macrocode} |
| 969 |
% The label contents are saved in a box called |\this@label|, formed as |
| 970 |
% a raggedright minipage of width |\area@width|. The trick is to make |
| 971 |
% the end of line character into a macro |^^M| which gets executed each |
| 972 |
% time it is encountered. By testing for blank lines, we can find the |
| 973 |
% end of a series of consecutive address lines and cause the macro to |
| 974 |
% terminate the label box definition, and possibly start another. The |
| 975 |
% usual action taken on intercept of an end of line character is to |
| 976 |
% insert |\newline|. It is only the case of a blank line that causes |
| 977 |
% us to end the current label. Here, swallow a pending \verb|^M|, to |
| 978 |
% avoid having a blank line at the start of each label. Extra blank |
| 979 |
% lines cause blank labels, which are thrown away when encountered, |
| 980 |
% later on. A technical point: we cannot use \verb|\sbox|, as |
| 981 |
% otherwise \TeX\ gets confused, attempting to use \verb|\bgroup| as |
| 982 |
% the second argument to \verb|\sbox|, which is not what we want. |
| 983 |
% \begin{macrocode} |
| 984 |
\def\start@@label{% |
| 985 |
\begin{lrbox}{\this@label}% |
| 986 |
\begin{minipage}{\area@width}\raggedright% |
| 987 |
\catcode `\^^M =\active\@gobblecr% |
| 988 |
} |
| 989 |
\def\end@@label{% |
| 990 |
\end{minipage}\end{lrbox}% |
| 991 |
\sticky@label} |
| 992 |
% \end{macrocode} |
| 993 |
% |
| 994 |
% The principal support macros needed to define the |labels| environment |
| 995 |
% will be defined below. These macros assume names and addresses appear |
| 996 |
% as consecutive lines separated by a blank line. If we are in the |
| 997 |
% middle of consecutive address lines, then just start a new line. |
| 998 |
% \begin{macrocode} |
| 999 |
\def\start@newline{\mbox{}\expandafter\newline}% |
| 1000 |
% \end{macrocode} |
| 1001 |
% If we have met a blank line, then finish the current label and start a |
| 1002 |
% new label. |
| 1003 |
% \begin{macrocode} |
| 1004 |
\def\new@label{\end@@label\start@@label}% |
| 1005 |
% \end{macrocode} |
| 1006 |
% The macro |^^M| invokes either |\start@newline| or |\new@label|. To |
| 1007 |
% define it, we use some hackery from Phil Taylor. Step one is to |
| 1008 |
% activate a control sequence at end of line. |
| 1009 |
% \begin{macrocode} |
| 1010 |
\catcode `\^^M = \active% |
| 1011 |
% \end{macrocode} |
| 1012 |
% The opaque definition required uses |futurelet| to selectively expand |
| 1013 |
% a control sequence during a definition. The macro |^^M| is supposed to |
| 1014 |
% replace carriage returns by |\newline|, or else end this label and |
| 1015 |
% start a new one with |\new@label|. The idea is to define |^^M| to be a |
| 1016 |
% control sequence |\nexttoken|, active only when |^^M| has been made an |
| 1017 |
% active control sequence. Then the expansion of |^^M{#1}| will be |
| 1018 |
% |\nexttoken|, provided the next line |#1| following the current one |
| 1019 |
% has no characters (except carriage return at the end). Otherwise, we |
| 1020 |
% must be at the start of a new cluster of label lines. |
| 1021 |
% \begin{macrocode} |
| 1022 |
\def ^^M{\futurelet\nexttoken\isitapar}% |
| 1023 |
\def\isitapar{\ifx^^M\nexttoken\let\action=\new@label\else% |
| 1024 |
\let\action\start@newline\fi\action}% |
| 1025 |
% \end{macrocode} |
| 1026 |
% Definitions involving |^^M| are finished. Re-instate the original |
| 1027 |
% catcode for carriage-return. |
| 1028 |
% \begin{macrocode} |
| 1029 |
\catcode `\^^M = 5\relax% |
| 1030 |
% \end{macrocode} |
| 1031 |
% The syntax of the |labels| environment can be shortened to a single |
| 1032 |
% line, provided an input file name is known and the contents have been |
| 1033 |
% prepared for use with the |labels| environment. |
| 1034 |
% \begin{macrocode} |
| 1035 |
\def\labelfile#1{\begin{labels}\input#1\end{labels}} |
| 1036 |
% \end{macrocode} |
| 1037 |
% In the interest of a general engine for label production, the program |
| 1038 |
% can prompt for the file name at runtime. This kind of feature makes it |
| 1039 |
% possible to run one batch file to create labels, regardless of the |
| 1040 |
% source. |
| 1041 |
% \begin{macrocode} |
| 1042 |
\def\promptlabels{\typein[\labelfilename]{What is the name of the |
| 1043 |
label file?} |
| 1044 |
\labelfile{\labelfilename}} |
| 1045 |
% \end{macrocode} |
| 1046 |
% It is possible that a number of empty labels should be printed before |
| 1047 |
% going on to print the next set of labels. |
| 1048 |
% The |\skiplabels| macro takes an |
| 1049 |
% integer argument of the number of empty labels to produce. An |x| is |
| 1050 |
% printed on the terminal for each such empty label. For example: |
| 1051 |
% \begin{verbatim} |
| 1052 |
% \documentclass{article} |
| 1053 |
% \usepackage{labels} |
| 1054 |
% \begin{document} |
| 1055 |
% \numberoflabels=19 |
| 1056 |
% \boxedaddresslabel{Me \\my street \\ mytown \\ England} |
| 1057 |
% \skiplabels{2}% Make 21 on first sheet |
| 1058 |
% \numberoflabels=16 |
| 1059 |
% \boxedaddresslabel{You \\your street \\ yourtown \\ England} |
| 1060 |
% \end{document} |
| 1061 |
% \end{verbatim} |
| 1062 |
% \begin{macrocode} |
| 1063 |
\newcount\sk@pped |
| 1064 |
\def\skiplabels#1{\sk@pped=#1% |
| 1065 |
\savebox{\this@label}{\rule{0pt}{.5in}}% |
| 1066 |
\skip@labels=0\relax |
| 1067 |
\loop\ifnum\skip@labels<\sk@pped\make@label% |
| 1068 |
\advance\skip@labels by 1\relax\repeat} |
| 1069 |
%</package> |
| 1070 |
% \end{macrocode} |
| 1071 |
% |
| 1072 |
% \section{History and acknowledgements} |
| 1073 |
% \begin{itemize} |
| 1074 |
% \item (SPQR) v.1, May 9th 1989 simply allowed |
| 1075 |
% for |\addresslabel{... \\ ...\\...}| |
| 1076 |
% \item (SPQR) v.2, July 15th permitted verbatim style with no explicit end of lines |
| 1077 |
% \item (SPQR) v.3, March 1991 made more generic |
| 1078 |
% \item (SPQR) v.4, January 1992 checked and made to work with emtex drivers |
| 1079 |
% to my satisfaction, and documented to bare-bones level with `doc' system. |
| 1080 |
% \item (SPQR) v.5, March 1993 allowed for |\skiplabels| |
| 1081 |
% \item (SPQR) v.6, January 1994 for \LaTeXe |
| 1082 |
% \item (SPQR) v.7, January 1994 fixes |
| 1083 |
% \item (SPQR) v.8, April 1994 revised .dtx file |
| 1084 |
% \item (GG) v.9, April 1995 revised .dtx file to Package so it |
| 1085 |
% works with |article|, |report| and |book| classes. |
| 1086 |
% Revisions by |[email protected]|. |
| 1087 |
% Made source independent of paper size (it depended on a4 paper). |
| 1088 |
% Fixed extra space bug in tabular array of |\addresslabel| - |
| 1089 |
% it did not reproduce results of the |labels| environment. |
| 1090 |
% Minipage lines weren't ragged, now they are. |
| 1091 |
% New controls to set spaces around labels. Corrected the label |
| 1092 |
% placement computations. Error reporting for labels that |
| 1093 |
% are too big for the set dimensions. Report in millimeters. |
| 1094 |
% Invoked label setup at runtime. New |\boxedaddresslabel[#1]{#2}|. |
| 1095 |
% Micrometer placement of label grid on the page. Introduced empty |
| 1096 |
% label algorithm. Got rid of strange error messages. |
| 1097 |
% \item (GG) v.9, May 1995. |newenvironment{labels}| failed under \LaTeX{} |
| 1098 |
% 2.09 (1991), but worked under later versions! Defining |\labels| |
| 1099 |
% and |\endlabels| fixed the problem. |
| 1100 |
% \item (SPQR) v.10, June 1995. Checked and issued. |
| 1101 |
% \item (GG) v.11, January 1998. |
| 1102 |
% New counter |\LabelTotal| and page eject when this counter is |
| 1103 |
% zero. |
| 1104 |
% Beta version April 1996, released January 1998. Documented |
| 1105 |
% \LaTeX{}209 style file |olabels.sty|. |
| 1106 |
% \item (JDG) v.12, January 2002. |
| 1107 |
% Introduced more natural dimension description system, which |
| 1108 |
% is activated by the `|newdimens|' package option. This is only |
| 1109 |
% implemented for the \LaTeXe\ version. |
| 1110 |
% \item (JDG) v.13, May 2003. |
| 1111 |
% Bug fix release: don't break with the color package (thanks |
| 1112 |
% to Dominique de Waleffe for reporting it) |
| 1113 |
% |
| 1114 |
% \end{itemize} |
| 1115 |
% The crucial macros which make the system bearable for mailing lists |
| 1116 |
% by redefining end of line came from Phil Taylor; apologies |
| 1117 |
% to him for using them in a \LaTeX\ style file! |
| 1118 |
% |
| 1119 |
% \Finale |
| 1120 |
\endinput |
| 1121 |
%% \CharacterTable |
| 1122 |
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 1123 |
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 1124 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 1125 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 1126 |
%% Dollar \$ Percent \% Ampersand \& |
| 1127 |
%% Acute accent \' Left paren \( Right paren \) |
| 1128 |
%% Asterisk \* Plus \+ Comma \, |
| 1129 |
%% Minus \- Point \. Solidus \/ |
| 1130 |
%% Colon \: Semicolon \; Less than \< |
| 1131 |
%% Equals \= Greater than \> Question mark \? |
| 1132 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 1133 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 1134 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 1135 |
%% Right brace \} Tilde \~} |