Printing Envelopes and Labels in L^{A}TEX 2ε:

EnvLab Package. User Guide^{∗}

Boris Veytsman

June 15, 1996

Abstract This package provides a comprehensive and easily customizable system for creating mailing envelopes and labels in L^{A}TEX 2ε. Includes printing barcodes and address formatting according to the US Postal Service rules.

Contents

1 Introduction 2 2 Installation 2 3 Usage 3

3.1 The basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.2 Sizes of labels and envelopes . . . . . . . . . . . . . . . . . . . . . 6 3.3 Printing details . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.4 Formatting of the address (barcodes and capitalization) . . . . . 10 3.5 Printing of return addresses . . . . . . . . . . . . . . . . . . . . . 11

4 Customization 11 5 Bugs and limitations 12 6 Legalese 13 References 13

List of Figures

1 Automatic generation of envelopes . . . . . . . . . . . . . . . . . 4 2 EnvLab and mailing package. . . . . . . . . . . . . . . . . . . . . 4 3 Manual generation of envelopes . . . . . . . . . . . . . . . . . . . 5 4 Printing of return labels . . . . . . . . . . . . . . . . . . . . . . . 5 5 Labels parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 7

∗\begin{matrix}c \\ ◯ \end{matrix}Boris Veytsman, 1996

List of Tables

1 Standard envelope sizes . . . . . . . . . . . . . . . . . . . . . . . 6 2 Standard label sizes . . . . . . . . . . . . . . . . . . . . . . . . . 7

1 Introduction

The standard \makelabels command in the L^{A}TEX 2ε letter.cls document class typesets labels on Avery 5352 sheets. A typical user may want more. EnvLab redefines \makelabels in^{1} a more useful and customizable way. EnvLab:

• Typesets mailing labels or envelopes on a number of pre-defined label sheets or envelopes.

• Can be easily configured for any customized label or envelope sizes. The rule of thumb is: if you printer can print this, EnvLab can typeset this.

• Can optionally print barcodes and/or process addresses according to the United States Postal Service Rules.

• Allows you to include your logo in the return address.

• Painlessly interacts with mail merging packages such as mailing.

• Does not require special fonts for address and barcodes printing. The typesetting is implemented with standard fonts and L^{A}TEX \rule commands.

This package was written with US mailing standards in mind. This is not a reflection of the author’s americanocentrism: US standard was only one I had official documents about. If you want to add your national standards, please contact me with pointers to the corresponding documents.

This document describes the basic usage of the package. More sophisticated users would want to typeset and browse envlab.dtx as well.

2 Installation

The distribution of this package includes the following files:

1. envlab.dtx—fully documented program, 2. envlab.ins—DocStrip instruction module,

1hopefully

3. elold.ins—DocStrip instruction module for older versions of DocStrip,

4. elguide.tex (this file)—User Guide,

5. readme.version number—ReadMe file.

To install the package

1. L^{A}TEX the file envlab.ins^{2}. It will produce three files: envlab.drv,

     envlab.sty and envlab.cfg.

2. (Optional) Look at the file envlab.cfg and change it accordingly to your taste (see Section 4).

3. Move the files envlab.sty and envlab.cfg to the L^{A}TEX search path

4. Produce the documentation by L^{A}TEXing the files elguide.tex and (op-

     tional) envlab.drv.

5. Enjoy!

3 Usage

3.1 The basics

The package EnvLab is intended to be used with the L^{A}TEX 2ε letter document class and similar custom classes. The standard document class defines the environment letter, which, among other things, writes to the main .aux file the information about mailing address. EnvLab retrieves and typesets this information. In general one should not use EnvLab with document classes that do not provide this information. The package types an error message if it cannot find the makelabels command in the class it is called from^{3}.

There are three ways to use EnvLab:

3.1.1 Automatic generation of envelopes or labels

\makelabels

Put in the preamble of your document: \usepackage[⟨options⟩]{envlab} and \makelabels. The package will generate envelopes or labels at the end of your document, ready to be printed. An example of such usage is shown on Fig. 1.

An interesting extension of this method is the use of EnvLab with mail-merge packages. If such packages generate letter environments, then EnvLab will happily produce envelopes or labels for them. I tested EnvLab with the mailing package available at CTAN with excellent results. See an example on Fig. 2.

2If your docstrip.tex is earlier than version 2.3, use elold.ins instead of envlab.ins.

3If you want to create a custom letter class to be used with EnvLab, take care to write commands \startlabels and \mlabel{from-address}{to-address} to the .aux file. Also define a \makelabels command. The latter can do anything—EnvLab will redefine it anyway, but the package needs to see \makelabels defined at the start up

\documentclass[12pt]{letter}
\usepackage[personalenvelope]{envlab}
\makelabels
\address{%
  Joe Casanova\\1 Lambda Street\\Anyplace, NY 12345}
\signature{Joe}
\begin{document}
\begin{letter}{%
  Mary McKeen\\2 Alpha Street\\Otherplace, NY 12346}
  \opening{Dear Mary:}
  I love only you
  \closing{With love,}
\end{letter}
\begin{letter}{%
  Lisa O'Hara\\2 Beta Street\\Anotherplace, NY 12347}
  \opening{Dear Lisa:}
  I love only you
  \closing{With love,}
\end{letter}
\end{document}

Figure 1: Automatic generation of envelopes

\documentclass[12pt]{letter}
\usepackage[avery5061label,alwaysbarcodes]{envlab}
\makelabels
\address{%
Joe Casanova\\1 Lambda Street\\Anyplace, NY 12345}
\signature{Joe}
\usepackage{mailing}
\addressfile{lovers.dat}
\mailingtext{%
  I love only you
  \closing{With love,}}
\begin{document}
\makemailing
\end{document}

Figure 2: EnvLab and mailing package. The file lovers.dat contains the address data in the format described in the documentation for mailing package.

       \usepackage[businessenvelope]{envlab}
       \makelabels
       \begin{document}
       \startlabels
       \mlabel{%
         Joe Casanova\\1 Lambda Street\\Anyplace, NY 12345}{%
         Mary McKeen\\2 Alpha Street\\Otherplace, NY 12346}
       \mlabel{%
         Joe Casanova\\1 Lambda Street\\Anyplace, NY 12345}{%
         Lisa O'Hara\\2 Beta Street\\Anotherplace, NY 12347}
       \end{document}

Figure 3: Manual generation of envelopes

       \documentclass[12pt]{letter}
       \usepackage[avery5160label,noprintbarcodes,%
       nocapaddress]{envlab}
       \makelabels
       \begin{document}
       \printreturnlabels{180}{%
         Joe Casanova\\1 Lambda Street\\Anyplace, NY 12345}
       \end{document}

Figure 4: Printing of return labels

3.1.2 Manual generation of envelopes or labels

\startlabels, \mlabel{from-address}{to-address}

Sometimes you need to generate only mailing labels or envelopes, but not letters themselves. In this case prepare a separate document of letter document class. Put in the preamble of your document \usepackage[⟨options⟩]{envlab} and \makelabels, and in the body of your document the command \startlabels^{4}, and commands \mlabel{from-address}{to-address} for each label you want to generate (see Fig. 3)

3.1.3 Printing of return labels

\printreturnlabels{number}{text}

Sometimes you need to print only return labels. To print {number} of labels with the {text} on each use the command \printreturnlabels{number}{text}. It is better to put it in a separate document (see Fig. 4).

4It sets up page parameters for envelopes and letters

Package option  Width Height
businessenvelope  9.5′′  4.125′′
executiveenvelope  7.5′′  3.875′′
bookletenvelope  10.5′′  7.5′′
personalenvelope  6.5′′  3.625′′
c6envelope  162 mm 114 mm
c65envelope  224 mm 114 mm
c5envelope  229 mm 162 mm

Table 1: Standard envelope sizes

3.2 Sizes of labels and envelopes

EnvLab package makes a distinction between envelopes and labels. The differences are:

• Envelopes are printed on separate pages, labels are printed several per page

• Envelopes might have return address, labels might not

• Envelopes are rotated by default, labels are never rotated

businessenvelope, executiveenvelope, bookletenvelope, personalenvelope,
c6envelope, c65envelope, c5envelope

EnvLab knows about a number of standard envelopes. The options listed in Table 1 are used to typeset the addresses for envelopes with the given width and height. For example, if you have 9.5′′ × 4.125′′ envelopes, use the command

\usepackage[businessenvelope]{envlab}.

\SetEnvelope[⟨top margin⟩]{width}{height}

If your envelope is not listed in Table 1, put in the preamble of your document the command \SetEnvelope{width}{height}^{5}. Its arguments are dimensions of your envelope (together with the units!). For example, if you have 8′′ × 4′′ envelopes, use the command \SetEnvelope{8in}{4in}.

avery5160label, avery5161label, avery5162label,
avery5163label, avery5164label

EnvLab knows also about a number of commercially available labels. They are listed in Table 2. The dimensions W and H are the label total width and height, t and l are the distance between the edge of the paper and the label (see Fig. 5). The numbers N_{c} and N_{r} are correspondingly the numbers of columns and rows of labels on a sheet.

5The optional first argument of this command is described in Section 3.3

[figure: H; l; t; r; W]

Figure 5: Labels parameters

Package option W  H  t  l  r  N_{c} N_{r}
avery5160label 2.75′′ 1′′  0.5′′ 0.19′′ 0.12′′ 3 10
avery5161label 4.19′′ 1′′  0.5′′ 0.16′′ 0.19′′ 2 10
avery5162label 4.19′′ 1.33′′ 0.83′′ 0.16′′ 0.19′′ 2 7
avery5163label 4.19′′ 2′′  0.5′′ 0.16′′ 0.19′′ 2 5
avery5164label 4.19′′ 3.33′′ 0.5′′ 0.16′′ 0.19′′ 2 3

Table 2: Standard label sizes

\SetLabel{W }{H}{t}{l}{r}{N_{c}}{N_{r}}

If your label size is not listed in Table 2, put in the preamble of your document the command \SetLabel{W }{H}{t}{l}{r}{N_{c}} {N_{r}}. This command is completely analogous to the command \SetEnvelope described above.

3.3 Printing details

EnvLab typesets envelopes or sheets of labels just after the main text of all letters in the documents. Most printers that have paper tray and manual feeding slot use manual slot if it is not empty and tray otherwise. When printing envelopes or labels on such printers, you wait until the text of letters is printed, and then insert envelopes or label sheets one by one in the manual feeding slot.

\AtBeginLabels{Printer specific commands} \AtBeginLabelPage{Printer specific commands}

However some printers have several paper trays and even paper trays for envelopes. Moreover, sometimes the switching between trays can be performed automatically by software commands. If you know such commands for your printer and know how to insert them in the .dvi file (e.g. through \specials), you can use the hook \AtBeginLabels. Put the printer specific commands in the argument of \AtBeginLabels. If you succeed, please e-mail me these commands and the specifications of your printer, so I can include them in the future releases of EnvLab. Note that the command \AtBeginLabels is cumu-

New feature Version 1.1

lative: if you use it several times in the same document, the new commands will be appended without overwriting the previous definitions. . The command

New feature Version 1.1

\AtBeginLabelPage works in the same way, but its argument will be inserted at the beginning of each page of EnvLab output, i.e. before printing each envelope or label sheet.

pswait, nopswait

If you use dvips, you can ask it to switch your printer to manual mode just

New feature Version 1.1

before printing envelopes and labels. The printer will print the main body of the letter(s) using the paper tray, and then stop, waiting for envelopes or label sheets to be fed in the manual slot. The option pswait, based on the code by William Slough <cfwas@eiu.edu>, inserts the corresponding PostScript specials in your output. The option nopswait (default) suppresses this behavior.

\PSwait

William Slough’s code can be useful in other situations when you need to switch

New feature Version 1.1

to manual mode in the middle of the document. The command \PSwait inserts the corresponding PostScript code in the dvips output. (An attentive reader has probably already guessed that the pswait option is implemented through

the command \AtBeginLabels{\PSwait}).

Note that there are differences in the handling of the text close to paper edges from printer to printer. Since envelopes and label sheets have text near the edges, you might need to tune the offsets. For labels you can use the command \SetLabel to do this. The optional first argument of the command \SetEnvelope sets the distance between the leading edge of “logical paper” and the physical leading edge of the envelope (0 pt by default).

rotateenvelopes, norotateenvelopes

Options for graphics package

Usually envelopes are printed in the landscape mode, i.e. rotated by 90^{∘}. The package options rotateenvelopes (default) and norotateenvelopes control the rotation. Note that if you want to rotate envelopes, you need the standard package graphics installed on your system. Also, you need a dvi driver that understands rotation commands of the graphics package. (I think currently only dvips does this). The package graphics is called internally by EnvLab. If you need to pass specific options to the graphics package, include it in the list of options of EnvLab. For example, the command

\usepackage[personalenvelope,dvips]{envlab} calls graphics with the op-
tion dvips.
centerenvelopes, leftenvelopes, rightenvelopes,
customenvelopes, \EnvelopeLeftMargin

Most of manual feeding slots accept non-standard paper (like envelopes) centered. However there are some printers that require non-standard paper to be pushed to the left or right end of the slot. The package options

centerenvelopes (this is the default option), leftenvelopes, rightenvelopes

and customenvelopes control the position of the envelope with respect to the slot. The first three options are self-explanatory. The fourth gives the control over the envelope positioning to the user. If you choose this option, you must set the length \EnvelopeLeftMargin before printing the envelopes. For example to shift the envelope for 2′′ from the left edge use

\setlength{\EnvelopeLeftMargin}{2in}
LabelOffsetRow, LabelOffsetCol,
\FirstLabel{Row}{Col}

Sometimes you need to print labels on a partially used sheet. The counters LabelOffsetRow and LabelOffsetCol (default values 1) set the position of the first label to print. You can change them using the \setlength command. Alternatively, you can use the command \FirstLabel{Row}{Col} to set

New feature Version 1.1

both counters simultaneously. For example, the command \FirstLabel{3}{2} causes EnvLab to start printing labels beginning with the second label in the third row. Note that labels are printed row by row (not column by column, like in the standard L^{A}TEX 2ε letter class).

3.4 Formatting of the address (barcodes and capitalization)

In the United States (and many other countries as well) the mailing pieces are sorted by machines. This process is greatly facilitated if the addresses typesetting is enhanced for machine readability.

USPS standards [1] establish two ways for making the addresses machine readable: barcodes and special printing of addresses for optical character recognition (OCR) devices. In principle any method would be sufficient, but it seems reasonable to play it safe using both methods. Therefore EnvLab by default both prints barcodes and prepares addresses for OCR. This behavior can be controlled through package options.

Note that only “To-Address” should be machine-readable. The return address can be formatted more freely. You can, for example, include your logo in the return address (see Section 4)

printbarcodes, noprintbarcodes

The addresses in the US contain “zipcodes”—strings of five digits (5-code) or 9 digits divided by dash (5+4 code). The 5+4 code is actually a detalization^{6}, so the zipcode 12345-6789 can be written as just 12345. This code is converted into a series of long and short bars and printed on a label or envelope. If the option printbarcodes (default) is selected, EnvLab tries to extract zipcode from the address and print it. It defines zipcode as a sequence of digits that:

1. Has no characters other than digits and dashes (-) inside it

2. Has no groups in braces ({})inside it and is not braced itself

3. Is the last in the address field

The option noprintbarcodes suppresses the typesetting of barcodes.

alwaysbarcodes, noalwaysbarcodes

Sometimes the rule 3 is too harsh. Consider, for example, the following address:

Mr. A. B. User 32 Omega Road Palo Alto Ca 12345 USA

Obviously it has a zipcode, however EnvLab normally will not see it. The option alwaysbarcodes lifts this restriction, and EnvLab typesets barcodes for the last number met in the address even if it is followed by some other characters. Be careful with this option! If you select it, all addresses must actually have zipcodes. Otherwise EnvLab will happily convert to bars a street or apartment number.

6There is an even finer detalization provided by the so called DPC numbers [1]. EnvLab does not support it yet

This option is especially useful if the addresses are not typed in manually, but are prepared by some mail merge program like mailing package. Then they can contain spaces at the end, and EnvLab will not recognize zipcodes unless alwaysbarcodes is selected. The option noalwaysbarcodes (default) suppresses this behavior.

capaddress, nocapaddress

To facilitate OCR EnvLab typesets addresses in 12pt sans serif font. The machine readability of the addresses is increased if the following recommendations of US Postal service are followed:

• Converting the addresses to uppercase

• Stripping punctuation from the addresses

• Inserting 1 pt kern between the letters

The result looks rather ugly for human eye. However, it is intended not for humans, but for machines. We will call this processing address capitalization. EnvLab performs capitalization of the “To-addresses” automatically if the option capaddress (default) is selected. The option nocapaddress suppresses capitalization of the addresses.

If you decide to capitalize the addresses, be careful with the accented letters. Since EnvLab processes the address letter by letter^{7}, it tries to insert kern between \" and u in the word M\"uller causing an error. Therefore all accented letters should be enclosed in braces. The correct way to typeset Herr. Müller is

Herr.~M{\"u}ller^{8}.

3.5 Printing of return addresses

printreturnaddress, noprintreturnaddress

The return addresses are printed on the envelopes if the package option

New feature Version 1.1

printreturnaddress (default) is chosen. Alternatively, the package option noprintreturnaddress suppresses the printing of the return address. Section 4 describes how to customize your return address.

4 Customization

Many people and companies want to print their logos on the envelopes. You can include any image in your return address. The macro \returnaddress controls the contents of the “From-address” field on your envelope. EnvLab takes it from the \address command in your document. However you can easily redefine it. For example, if the file mylogo.eps contains your logo, you put in the preamble

\returnaddress

7Rather, token by token

8I probably should strip all accents since they might confuse OCR. However USPS says nothing about accents, and I decided to preserve them.

\renewcommand{\returnaddress}{\protect\includegraphics{mylogo}} to

customize your envelopes. If you want return labels with your logo, use com-

mand like \printreturnlabels{180}{{\protect\includegraphics{mylogo}}.

You can include both logos and textual information into the \returnaddress

New description Version 1.1

macro. While customizing return address, it is useful to know that L^{A}TEX letter document class stores the contents of the \address command in the \fromaddress macro, so the default definition of the return address imple-

mented in EnvLab is \renewcommand{\returnaddress}{\fromaddress}.

Customization of lengths

All lengths (heights, widths, margins) are user-customizable. Consult the file envlab.dtx for their definitions and use.

envlab.cfg

If you use EnvLab for some time, you probably would have a number of options and commands that you execute in most documents prepared with the package. You can save the typing by putting such commands in the configuration file envlab.cfg. A sample configuration file is included in the EnvLab distribution. You are free to hack it in any way you like^{9}. This file consists of two parts:

\ExecuteOptions{options} and \AtEndOfPackage{customization commands}.

The options listed in the first part supersede the default options of EnvLab. However the options explicitly listed as the arguments of the \usepackage command supersede the options in the configuration file. The commands listed in the second part of the configuration file—as the arguments of the \AtEndOfPackage command—supersede all definitions in the package itself. Therefore by hacking envlab.cfg you can completely change the behavior of the package without modifying EnvLab.

5 Bugs and limitations

The most important limitation of EnvLab is related to an essential limitation

New description Version 1.1

of TEX itself. People usually want their envelopes printed rotated 90^{∘}, so the envelopes are inserted in the printed by the short side. Unfortunately TEX was not designed with the text rotation in mind. Therefore “basic” TEX does not allow to typeset envelopes in this manner. The standard L^{A}TEX 2ε package graphics uses PostScript to add this functionality to TEX. EnvLab uses graphics internally if the option rotateenvelopes (default) is in effect. Therefore to typeset rotated envelopes you need graphics and either a PostScript printer or ghostscript. Otherwise use norotatenvelopes option if your printed can process envelopes inserted by the long side. I understand that there is a problem with printing rotated text on non-PostScript printers. Probably the authors of dvi drivers should be urged to address it.

9Important: envlab.cfg is the only file you should modify. You are not allowed to modify any other files in the EnvLab distribution.

EnvLab thinks that all options it cannot understand belong to the graphics

New description Version 1.1

package and sends them there. Therefore if you misspell an option of the EnvLab package, you will receive an error message from the graphics package rather than from EnvLab.

Please send bug reports to boris@plmsc.psu.edu. You can find experimental versions of EnvLab at my homepage (http://planck.psu.edu/~boris).

6 Legalese

The package EnvLab is provided “as is” and comes with absolutely no warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. Should the program prove defective, you assume the cost of all necessary servicing, repair or correction.

In no event unless required by applicable law will the author of the program be liable to you for damages, including any general, special, incidental or consequential damages arising out of any use of the program or out of inability to use the program (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or by third parties as a result of a failure of the program to operate with any other programs), even if such holder or other party has been advised of the possibility of such damages.

In particular, while every effort was made to provide typesetting of mailing pieces accordingly to the United States Postal Service recommendations, the author of the package does not warrant neither successful delivery of mail nor granting of mailing discounts in the USA or any other countries.

EnvLab package is covered by the same license as the current L^{A}TEX 2ε package (see the files legal.txt and modguide.tex in the L^{A}TEX 2ε distribution).

Avery and all Avery codes are trademarks of Avery Dennison Corporation.

References

[1] USPS. Designing Business Letter Mail (Pub 25), August 1995.