From brunix!uunet!bellcore!att!ucbvax!CUNYVMS1.GC.CUNY.EDU!dlv Thu Feb 28 10:09:50 EST 1991
Article 5599 of comp.text.tex:
Path: brunix!uunet!bellcore!att!ucbvax!CUNYVMS1.GC.CUNY.EDU!dlv
>From: dlv@CUNYVMS1.GC.CUNY.EDU (Dimitri Vulis)
Newsgroups: comp.text.tex
Subject: LaTeX macros for POSTNET and FIM bar codes on envelopes
Message-ID: <00944e15.cdff08a0.5442@CUNYVMS1.GC.CUNY.EDU>
Date: 28 Feb 91 04:46:50 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Lines: 308


 
Unfortunately, it seems that my article will _not_ be appearing in TUGBoat.
So, I'm posting the (improved) macros and an example file here, and later I
will post the entire article and an explanation of why it's not in TB and what
I think about TB (nothing good :). I'll post now parts of the paper that are
highly relevant (being parts, they lack coherence :).
 
-------
 
Parts of documentation:
 
It is reported that recently the United States Postal Service board of
governors approved the 27-cent ``public automation rate'' for first-class mail
whose envelopes are pre-printed with a ZIP+4 code and a Postnet bar code,
versus the new 29-cent rate for first-class mail.
 
The vendors of commercial bar code printing programs claim that putting a
Postnet code and a facing identification mark on an envelope speeds up
delivery, but the post office denies this. My limited tests seem to indicate
that there is no speed-up for mail sent locally in New York City, but non-local
mail is sometimes delivered a day faster if it has pre-applied bar codes.
 
The post office does say that using postage meter imprints, which don't need to
be faced and canceled, instead of adhesive stamps, speeds up mail processing,
and saves time for the user.
 
By 1993 the Post Office plans to implement an 11-digit system, where the
additional two digits will be used to sequence the mail in route delivery
order. \TeX\ macros presented here should be compatible with this change.
 
\TeX\ is very good at making bar codes. Some years ago I used \MF\ to make 3 of
9 bar codes, and Peter Flynn pointed out that \TeX\ is very good with rules and
can be used to make bar codes by itself; so I wrote these macros.
 
Unfortunately, mail with FIMs, ZIP+4 codes, and bar codes looks like junk mail,
and recipients may throw it away without opening.
 
One shoud always give one's ZIP+4 code as part of one's snailing address. Users
of these macros are also likely to be faced with the problem of adding the
4-digit suffix to existing address files.
 
The Post Office says it will add ZIP+4 codes to a printout of an address list
for free. I have not tested this service, but it says one can print out the
contents of one's snailing address file, send it to the post office, and get it
back with the ZIP+4 codes added, which one can then add to one's file. The Post
Office also says it would accept a mailing list (between 350 and 50,000
entries) on a floppy disk (in ASCII format with fixed length fields), and
update it with ZIP+4 codes for free. (Ask for form 5603, ``Request for ZIP+4
coding of address files on diskettes''.)
 
There is a public-access terminal in New York Central Post Office which allows
one to key in one's addresses and obtain the corresponding ZIP+4 codes. I've
used to it update much of my address book to ZIP+4 codes. However, I found that
for many people I correspond with the only kind of snailing address I have is
of the form
 
{\addressfont\noindent
Prof.~Chaim R.~Shafarevich\\
Department of Algebraic Masonry\\
Emanuelle University\\
Smalltown, NY 10101
}
 
The public access terminal calls such an address insufficient (indeed, it lacks
the street address!), and refuses to give the ZIP+4 code. Experience shows that
mail addressed in this manner still gets delivered. The 10101 post office in
Smalltown knows where Emanuelle University is. Presumably, the same software is
used by the Post Office for its free service, so such addresses won't be
automatically ZIP+4-coded.
 
In such cases, I found that both the street address and the ZIP+4 code are
often found on preprinted departmental stationery, whose return address was
presumably composed by Emanuelle University's mailroom in cooperation with the
10101 post office. Occasionally, distinct departments have distinct ZIP+4
extensions. The stationery also sometimes includes an internal mail stop;
putting that on the envelope may make internal delivery faster after the post
office delivers the letter to Emanuelle University's mailroom.
 
Another source of ZIP+4 codes are pre-printed envelopes. For example, the
American Math Society lists only the 5-digit code 02940, but its preprinted
envelopes have the 9-digit code \ZipBar{02940-9943}\box\PostNetBox, which is,
one can easily see, 02940-9943. (Of course, this could be found via the post
office computer.)
 
For mail going outside of the US, the country name in capital letters should be
the only entry on the last line of the address. Endorsements for special
services (restriced delivery, do not forward, registered mail, forwarding and
address correction requested, etc) should be placed above and flush left with
the delivery address. All these data can be given as an argument to the
|\envaddress| macro.
 
I hard-coded Commercial~\#10 size; other common envelope sizes are Monarch,
3.875in~$\times$~7.5in, and in Europe: DL, 110mm~$\times$~220mm and C5,
162mm~$\times$~229mm.
 
It's possible to print several envelopes at once by repeatedly calling
|\begin{envelope}| and |\end{envelope}|.
 
There are absolutely no conventions about feeding envelopes into various
printers and telling the device driver to print landscape. With Eberhard
Mattes' excellent |dvihplj| driver and my unusual printer I seem to achieve
reasonable results with the options |/tr3 /l-1in /t3.5in| (rotate 90 degrees
clockwise, and change offsets). It's desirable to have the FIM facing the
inside, since most printers can't print on the outside edge. One needs to
discover the correct options and envelope feeding procedure for one's
driver/printer combination by trial and error.
 
The layout of database tables for mass mailing lists and for one's personal
correspondence is similar: each row should contain a unique identifier for
joining with other data tables, an optional salutation, and the complete
address (preferrably, with ZIP+4 code and carrier route, and room for ZIP+6).
But the operations are somewhat different for the two applications. For a mass
mailing list, it's desirable to detect similar entries (i.e., slight variations
of the same addressee) to avoid duplicate entries, and to be able to select a
random sample of a specified size (the so called $n$th sample, used for tests);
while for a personal address file it would be convenient to have a tool similar
in spirit to \BibTeX, where the user would reference only a name tag, or a name
and a department tag, in the \TeX\ file, and one or more clever programs would
pull the missing address information from the address table and complete the
letter and the envelope, just like \BibTeX\ retrieves references from tags in a
\LaTeX\ file.
 
I may eventually write such a program. Alas, the days when people wrote \TeX
ware and freely distributed it with source code are gone; crooks peddle
programs that other people wrote and use the name ``\TeX'' to refer to non-\TeX
s, against Knuth's wishes, and instead of being ostracized by the \TeX\ users'
community, they are permitted to advertize their wares in the TUGBoat, casting
doubts on this newsletter's editorial integrity. This will yet lead to \TeX's
demise. I try to deal with this problem by not talking to people that deal with
such crooks.
 
These macros have not been certified by the Post Office, and are not warrantied
to do anything at all. You may use them at your own risk. The certification
process costs \$375, and I'm not making any money by giving them away for free.
The macros are copyrighted, though.
 
 
----------
 
Example file:
 
% This is used to print one or more envelopes on the laser printer.
 
%\begin{envelope}
%Prof. Blah\\
%Department of Mathematics\\
%City, State Zip
%\ZipBar{Zip-Zip}
%\end{envelope}
 
\documentstyle[env]{article}
\nofiles
 
\textwidth9.5in
\textheight4.125in
\pagestyle{empty}
 
\begin{document}
 
\from{Dimitri Vulis}
 
\begin{envelope}
\envaddress{
Dimitri Vulis\\
Department of Mathematics/Box 330\\
Graduate School \& University Center\\
City University of New York\\
33 West 42 Street\\
New York, New York 10036
}
\ZipBar{10036-8099}
\end{envelope}
\end{document}
 
 
----------
 
 
The file env.sty:
 
% Copyright 1988, 1991 by Dimitri Vulis.
% All rights reserved.
\newbox\PostNetBox
\newbox\ZipBarL
\newbox\ZipBarS
\setbox\ZipBarL\hbox{\vrule \@height.125in
 \@width.020in\hskip.0276in}
\setbox\ZipBarS\hbox{\vrule \@height.05in
 \@width.020in\hskip.0276in}
\newcount\ZipBarm
\newcount\ZipBarn
\chardef\ten=10
 
%Almost like using \ifcase, but `-' is skipped
\def\ZipBar@@@#1#2{%
\expandafter\def\csname ZipBar@@#1\endcsname%
{#2\advance\ZipBarn#1\relax}}
 
\ZipBar@@@0{\copy\ZipBarL\copy\ZipBarL%
 \copy\ZipBarS\copy\ZipBarS\copy\ZipBarS}
\ZipBar@@@1{\copy\ZipBarS\copy\ZipBarS%
 \copy\ZipBarS\copy\ZipBarL\copy\ZipBarL}
\ZipBar@@@2{\copy\ZipBarS\copy\ZipBarS%
 \copy\ZipBarL\copy\ZipBarS\copy\ZipBarL}
\ZipBar@@@3{\copy\ZipBarS\copy\ZipBarS%
 \copy\ZipBarL\copy\ZipBarL\copy\ZipBarS}
\ZipBar@@@4{\copy\ZipBarS\copy\ZipBarL%
 \copy\ZipBarS\copy\ZipBarS\copy\ZipBarL}
\ZipBar@@@5{\copy\ZipBarS\copy\ZipBarL%
 \copy\ZipBarS\copy\ZipBarL\copy\ZipBarS}
\ZipBar@@@6{\copy\ZipBarS\copy\ZipBarL%
 \copy\ZipBarL\copy\ZipBarS\copy\ZipBarS}
\ZipBar@@@7{\copy\ZipBarL\copy\ZipBarS%
 \copy\ZipBarS\copy\ZipBarS\copy\ZipBarL}
\ZipBar@@@8{\copy\ZipBarL\copy\ZipBarS%
 \copy\ZipBarS\copy\ZipBarL\copy\ZipBarS}
\ZipBar@@@9{\copy\ZipBarL\copy\ZipBarS%
 \copy\ZipBarL\copy\ZipBarS\copy\ZipBarS}
 
\def\ZipBar@@#1{\csname ZipBar@@#1\endcsname}
 
\def\ZipBar@#1{%
 \ifx#1\null%
  \let\next\relax%
 \else%
  \ZipBar@@{#1}%
  \let\next\ZipBar@%
 \fi%
 \next}
 
\def\ZipBar#1{
 \ifx#1\empty\else% \ZipBar{}
 \setbox\PostNetBox\hbox{%
 \copy\ZipBarL% start with a frame bar
 \ZipBarn\z@%
 \ZipBar@#1\null%
 \ZipBarm\ZipBarn%
 \divide\ZipBarm\ten%
 \multiply\ZipBarm\ten%
 \advance\ZipBarm-\ZipBarn%
 \ifnum\ZipBarm<0%
  \advance\ZipBarm\ten%
 \fi%
 \ZipBar@@{\the\ZipBarm}% correction digit
 \copy\ZipBarL% end with a frame bar
 }%
 \fi% if empty
 }
 
\newbox\FIMbox
\setbox\FIMbox\vbox{%
 \hrule\@height.625in\@width.031in}
\setbox\FIMbox\hbox{\copy\FIMbox
 \hskip.0315in\copy\FIMbox\hskip.1565in%
 \copy\FIMbox\hskip.1565in%
 \copy\FIMbox\hskip.0315in\copy\FIMbox}
\newif\if@FIM
 
\newbox\AddressBox
\newbox\FromBox
 
\setbox\FromBox\null
 
\let\addressfont\twlsf
 
\def\EnvMakeBox#1#2{
\setbox#1\vbox{
\parindent0pt
\leftskip0pt
\lineskip1pt
\baselineskip12pt
\rightskip\@flushglue
\addressfont #2}}
 
\def\envaddress#1{\EnvMakeBox\AddressBox{#1}}
\def\from#1{\EnvMakeBox\FromBox{#1}}
 
% defaults are FIM and no Postnet
\def\envelope{
\@FIMtrue
\setbox\PostNetBox\null
\setbox\AddressBox\null
}
 
\def\endenvelope{
\newpage
\if@FIM
 \vbox to 0pt{
 \hbox to \hsize{\hfill \copy\FIMbox\hskip2in}
 \vss}
\fi
% These magic numbers are for our stationery
\vbox{\vskip.435in\hbox{\hskip.32in\copy\FromBox}}
\vfill
\vbox to0pt{\vss
% Address is 1 inch from the left
% and 1 inch from the bottom
\hbox{\hskip1in\box\AddressBox}
\vskip.375in}
\vbox to .625in{
 \vfill
 \hbox to \hsize{
  \hfill
  \hbox to 3.875in{
  \unhbox\PostNetBox\hfill}}
  \vskip.25in
}}


