rsingh@elaine0.stanford.edu (Rajesh Kumar Singh) (02/08/91)
Hello, Has anyone tried writing a command in tex or latex that would print the Zipcode bars? Something like \zipcode{12345}{1234} that prints the long and short vertical bars as mass mailing companies and postoffice do. Ideally, this should work with just one argument as well for the case one doesn't have a zip+4 number. aeems recursive enough to require only a few lines of latex. Comments, ideas, solutions? --raj -- Rajesh Kumar Singh E-mail: rsingh@portia.stanford.edu Dept of Civil Engineering or rsingh@cive.stanford.edu Blume Earthquake Center, Stanford University, Stanford, CA 94305 Phone: +1 415-723-1502 Fax: ...5-8662 Home: ...7-7773
moss@cs.umass.edu (Eliot Moss) (02/08/91)
It's not clear to me that you need to worry about having two args for Zip+4. Just encode whatever digits the user gives you, with the check digit, etc. You could check for # digits = 5 or 9 for sanity, I guess ..... Eliot -- J. Eliot B. Moss, Assistant Professor Department of Computer and Information Science Lederle Graduate Research Center University of Massachusetts Amherst, MA 01003 (413) 545-4206, 545-1249 (fax); Moss@cs.umass.edu
dsmith@applga.aa.cad.slb.com (J. Daniel Smith) (02/11/91)
In article <1991Feb7.175608.5783@portia.Stanford.EDU> rsingh@elaine0.stanford.edu (Rajesh Kumar Singh) writes: >Hello, > >Has anyone tried writing a command in tex or latex >that would print the Zipcode bars? Something like >\zipcode{12345}{1234} that prints the long and short >vertical bars as mass mailing companies and postoffice I played around with this about a year or so ago... (Someone posted PostScript code to do this in comp.lang.postscript, and I wanted to show it could be done in TeX, too). The following macro file is what I finally ended up with. If I remember correctly, some of the code was snarfed from another .STY file, but like a total idiot, I forgot to mention that in the STY file at the time.... I've also hacked together a few TeX macros for using printing the ZIP code exactly where the USPS wants it on an envelope, along with typesetting the address in USPS preferred style. Its been a while since I've done much with them, but if anybody want to take a look, let me know... Dan --- % % J. Daniel Smith % 24 May 1990 % % Modified from a STY file snarfed from someplace else. But I don't % remember where the original code came from... OOPS!!! % % Make a barcode for a ZIP code! % % Example usage is below. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \catcode`@=11 % letter % % Dimensions of bars to be used in the barcode \newdimen\b@rwidth \newdimen\b@rlong \newdimen\b@rshort \newdimen\b@rsep \b@rwidth=0.02true in \b@rlong=0.125true in \b@rshort=0.05true in \b@rsep=0.0275true in \def\sb@r{\vrule height\b@rshort width\b@rwidth depth0pt \kern\b@rsep} \def\lb@r{\vrule height\b@rlong width\b@rwidth depth0pt \kern\b@rsep} % The barcodes for each digit \def\zerob@r{\lb@r\lb@r\sb@r\sb@r\sb@r} \def\oneb@r{\sb@r\sb@r\sb@r\lb@r\lb@r} \def\twob@r{\sb@r\sb@r\lb@r\sb@r\lb@r} \def\threeb@r{\sb@r\sb@r\lb@r\lb@r\sb@r} \def\fourb@r{\sb@r\lb@r\sb@r\sb@r\lb@r} \def\fiveb@r{\sb@r\lb@r\sb@r\lb@r\sb@r} \def\sixb@r{\sb@r\lb@r\lb@r\sb@r\sb@r} \def\sevenb@r{\lb@r\sb@r\sb@r\sb@r\lb@r} \def\eightb@r{\lb@r\sb@r\sb@r\lb@r\sb@r} \def\nineb@r{\lb@r\sb@r\lb@r\sb@r\sb@r} \newcount\zipb@rm \newcount\zipb@rn \chardef\ten=10 %Almost like using \ifcase... except `-' is ignored. \def\zipb@r@@@#1#2{\expandafter\def\csname zipb@r@@#1\endcsname% {#2\advance\zipb@rn#1\relax}} \newbox\zipbarcode \zipb@r@@@0{\global\setbox\zipbarcode\hbox{\box\zipbarcode\zerob@r}} \zipb@r@@@1{\global\setbox\zipbarcode\hbox{\box\zipbarcode\oneb@r}} \zipb@r@@@2{\global\setbox\zipbarcode\hbox{\box\zipbarcode\twob@r}} \zipb@r@@@3{\global\setbox\zipbarcode\hbox{\box\zipbarcode\threeb@r}} \zipb@r@@@4{\global\setbox\zipbarcode\hbox{\box\zipbarcode\fourb@r}} \zipb@r@@@5{\global\setbox\zipbarcode\hbox{\box\zipbarcode\fiveb@r}} \zipb@r@@@6{\global\setbox\zipbarcode\hbox{\box\zipbarcode\sixb@r}} \zipb@r@@@7{\global\setbox\zipbarcode\hbox{\box\zipbarcode\sevenb@r}} \zipb@r@@@8{\global\setbox\zipbarcode\hbox{\box\zipbarcode\eightb@r}} \zipb@r@@@9{\global\setbox\zipbarcode\hbox{\box\zipbarcode\nineb@r}} \def\zipb@r@@#1{\csname zipb@r@@#1\endcsname} \def\zipb@r@#1{\ifx#1\null \let\next\relax \else \zipb@r@@{#1}#1% \let\next\zipb@r@ \fi \next} \def\zipbar#1{\setbox\zipbarcode=\null \hbox{ % put numbers in an \hbox \global\setbox\zipbarcode\hbox{\box\zipbarcode\lb@r} % start with long bar \zipb@rn\z@\zipb@r@#1\null \zipb@rm\zipb@rn \divide\zipb@rm\ten \multiply\zipb@rm\ten \advance\zipb@rm-\zipb@rn \ifnum\zipb@rm<0 \advance\zipb@rm\ten \fi \zipb@r@@{\the\zipb@rm} % last digit, so that the sum is divisible by ten \global\setbox\zipbarcode\hbox{\box\zipbarcode\lb@r}% end with a long bar } % end of \hbox } \catcode`@=12 % disable private sequences %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %\zipbar{1234567890} % %\zipbar{48837} % %\zipbar{78653--0102} %\bye \endinput -- =========================================================================== J. Daniel Smith Internet: dsmith@applga.aa.cad.slb.com Schlumberger CAD/CAM BITNET: smithdan@msuegr Ann Arbor, Michigan Usenet: uunet!sharkey!applga!dsmith
knurlin@canopus.trw.com (Scott Karlin) (02/13/91)
In article <1991Feb11.141820.5857@applga.aa.cad.slb.com> dsmith@applga.aa.cad.slb.com (J. Daniel Smith) writes: >I've also hacked together a few TeX macros for using printing the >ZIP code exactly where the USPS wants it on an envelope, along with >typesetting the address in USPS preferred style. Its been a while >since I've done much with them, but if anybody want to take a look, >let me know... Please post! -- Scott Karlin knurlin@spf.trw.com -- TRW Data Systems Center Phone: (213) 812-7335 -- One Space Park O2-1761 -- Redondo Beach, CA 90278 -- -- Scott Karlin knurlin@spf.trw.com -- TRW Data Systems Center Phone: (213) 812-7335 -- One Space Park O2-1761 -- Redondo Beach, CA 90278
dsmith@applga.aa.cad.slb.com (J. Daniel Smith) (02/14/91)
In article <27B84445.3EA0@deneva.sdd.trw.com> knurlin@canopus.trw.com (Scott Karlin) writes: >In article <1991Feb11.141820.5857@applga.aa.cad.slb.com> dsmith@applga.aa.cad.slb.com (J. Daniel Smith) writes: >>I've also hacked together a few TeX macros for using printing the >>ZIP code exactly where the USPS wants it on an envelope, along with >>typesetting the address in USPS preferred style. Its been a while >>since I've done much with them, but if anybody want to take a look, >>let me know... >Please post! Ok, but there isn't a lot of documentation or instructions, and I don't have the time right now to fix things up the way they should be. In addition to the "zip.tex" I posted earlier, two more files are needed: "lettermac.tex" and "make-env.tex". Both of these files are included in this posting, along with "test.adr" (a short test file for making an envelope), and "zip.tex" (again for convenience, its pretty short). Here is sample usage: % tex make-env This is TeX, C Version 3.1 (/usr/jupiter3/dsmith/tex/inputs/make-env.tex (/usr/jupiter3/dsmith/tex/inputs/lettermac.tex) (/usr/jupiter3/dsmith/tex/inputs/zip.tex) Letter address file Enter the name of the address file: test (test.adr) [1] ) Output written on make-env.dvi (1 page, 968 bytes). Transcript written on make-env.log. % Let me know about questions/problems/improvements/etc... Dan --- % test.adr % % J. Daniel Smith % 13 February 1991 % % sample test address for "make-env.tex" macros % \setaddress{John Q. Doe \\ 1234 Main Street \\ Anytown, USA \zipbar{12345-6789}} --- % lettermac.tex % % J. Daniel Smith % 8 November 1989 % % Simple macros for writing letters % % Last Updated: % JDS 23 May 90 % % don't indent paragraphs \newdimen\oldparindent \oldparindent=\parindent \parindent=0pt % % don't do so much complaining \tolerance=10000 \hbadness=9999 \vbadness=9999 % % make \narrower work correctly with \parindent \def\narrower{\advance\leftskip by\oldparindent \advance\rightskip by\oldparindent} % % leave a blank line between paragraphs \parskip=10pt plus 1pt minus 0.5pt % % page breaks between paragraphs when possible \interlinepenalty=1000 % % skip over a bit on the page \def\info#1{\hskip.6\hsize#1\par\par} % % of course, we don't want page numbers \nopagenumbers % % turn off hyphenation \pretolerance=10000\hyphenpenalty=10000 % % get the name of the address file from the user \def\getaddress#1{\begingroup \newlinechar=`@ \def\\{@} \message{@#1} \message{@Enter the name of the address file: } \endlinechar=-1 \read-1 to\AddressFileName \global\edef\InputAddressFileName{\AddressFileName.adr} \endgroup \obeyspaces % keep spaces in address % Make it easier to type '#' and '&' in addresses \catcode`\#=12\catcode`\&=12 \input\InputAddressFileName \catcode`\#=6\catcode`\&=4 \let\getaddress\relax} % % address at top of letter \def\setaddress#1{\gdef\Xaddress{#1}} \setaddress{\hbox{\bf * ADDRESS *}} \def\address{\par{\vskip\parskip\parskip=0pt\def\\{\par} \frenchspacing\Xaddress} \par\let\address\relax} % % Various items that might be used throughout the letter. Defaults % are set to something obnoxious so that if they are used without % being set it will be obvious \def\settitle#1{\gdef\Xtitle{#1}} \settitle{\hbox{\bf * TITLE *}} \def\title{\Xtitle} % \def\setfirstname#1{\gdef\Xfirstname{#1}} \setfirstname{\hbox{\bf * FIRSTNAME *}} \def\firstname{\Xfirstname} % \def\setlastname#1{\gdef\Xlastname{#1}} \setlastname{\hbox{\bf * LASTNAME *}} \def\lastname{\Xlastname} % \def\setcompany#1{\global\def\Xcompany{#1}} \setcompany{\hbox{\bf * COMPANY *}} \def\company{\Xcompany} % % addressee \def\addressee{Dear \Xtitle\ \Xlastname,\par} % % attn for envelopes \def\attn#1{\gdef\Xattn{Attn: #1}} % \gdef\attn{\par\vfill\line\bgroup\hbox{Attn: \Xattn}\hfil}} \let\Xattn=\relax % don't do anything unless its \attn is used % % ZIP code. For compatability with envelope macros. \let\zipbar=\relax % closings \def\signature#1#2{\vskip\parskip{\vbox{\info{#1,}\vskip.35true in\info{#2}} \let\signature\relax}} \def\sincerely#1{\signature{Sincerely}{#1}\let\sincerely\relax} \def\love#1{\signature{Love}{#1}\let\love\relax} % % cc: \def\cc#1{\par{\vskip\parskip\parskip=0pt\def\\{\par} {\rm cc: }\everypar={\phantom{\rm cc: }}#1} \let\cc\relax} % RE: \def\re#1{\par{\vskip\parskip\parskip=0pt\def\\{\par} {\rm RE: }\everypar={\phantom{\rm RE: }}#1} \let\re\relax} % % The date at the top of the letter % If a date is not set, then the current date is used. \def\Xtoday{\number\day\space\ifcase\month\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi \space\number\year} \def\today#1{\gdef\Xtoday{#1}} \def\date{\info{\Xtoday}\let\date\relax} --- % make-env.tex % % J. Daniel Smith % 12 January 1990 % % Print an address on an envelope according to strict USPS standards. % % Usage: % Place the address in a file with an extension of .adr. The % address is set with the \setaddress command, and \\ is used to % break lines. The \setattn command can be used if desired to % direct the letter to someones attention. % % Since this file is also ususally included into a letter, it is % also an easy spot to set other things that pertain to the letter % itself such as \firstname, etc. % % These macros use the "landscape" \special of dvips. The exact % syntax for other drivers might be slightly different. % % Bugs: % The \fontdimen parameters aren't restored after the address is % set, so the Attn: line also uses the strict USPS spacing which I % don't think is really necesary. The paremeters should be reset so % that the Attn: line will look better. % % various macros for setting up the information to appear on the % envelope. These are place in the lettermac.tex file so that the % same .adr file can be used with both letters and envelopes. The % ones of primary importance for envelopes are \setaddress and \attn % \input lettermac \input zip % ZIP code barcodes. This *must* be after lettermac.tex % % Hacks to get the size of the envelope right. These are for a legal % size envelope. \hsize=9.5true in\hoffset=0.5true in \vsize=4.125true in\voffset=1.1875true in % \special{landscape} % envelopes are printed in landscape mode % % The USPS has very specific guidelines about printing the address on % an envelope. Of course, they will take just about anything, but % they like it if the address is in ALL CAPS with no punctuation. % 10 point Helvetica (cmss) is one of the recommended fonts with a % 14 point baseline. If you want to override the default setting, the % \envfont can be specified in the .adr file. \font\envfont=cmss10 at 10.95true pt % cmss10 is smaller than 10pt Helvetica %\font\envfont=helv at 10true pt % PostScript font Helvetica \baselineskip=14true pt % % Remove punctuation. This is done by making the punctuation % characters to be TeX's ignored characters. % Hopefully setting TeX's font parameters right will increase the % interword spaces to the 1em that the USPS likes. % % the \catcodes have to be set before the address is read in, since once it is % read in, the \catcodes are fixed and can not be changed. \catcode`.=9 \catcode`,=9 % 9 = ignored character % read in the address \getaddress{Letter address file} % restore the \catcodes changed above \catcode`\.=12 \catcode`\,=12 % % uppercase the address (from page 331 of the TeXbook) to make it the % way the USPS likes it. \Xaddress where the lettermac macros store % the address when it is read in. \def\next#1\endname{\uppercase{\def\Xaddress{#1}}} \expandafter\next\Xaddress\endname % %% for testing.... %%\vbox to \vsize{\hrule %% \centerline{top} %% \vfil %% \centerline{\vrule left\hfill right\vrule} %% \vfil %% \centerline{bottom} %% \hrule} %%\eject\end % % put the address on the envelope in the correct font. % The USPS wants the address in a box that extends from 5/8" from the % bottom of the envelope to 2 1/4" from the bottom. This works out to % be 1.625 inches total. With the font and baseline skip defined above, % this is more than 8 lines (9 is too many). % % \leftline{\returnaddress} % some type of return address \ \vfil % fill up with blank space \vbox to 2.25true in{ \vbox to 1.625true in{\envfont\leftskip=4.5true in % the \fontdimen parameters need to be changed % here in case a different \envfont has been % loaded. \fontdimen6\envfont=10true pt % size of an em \fontdimen2\envfont=10true pt % interword space \fontdimen3\envfont=1true pt % interword stretch \fontdimen4\envfont=1true pt % interword shrink \fontdimen7\envfont=0pt % extra space % the address \address\vfil} % % The USPS wants the start of the barcode no further than 4" from the % right edge of the envelope and no less than than 3 1/4". It % prefers between 3 7/8" and 4". In addition it must be 1/4" up % from the bottom (plus/minus 1/16"). This 0.25" is provided by the % Attn: line below. \vfil \rightline{\hbox to 4true in{\box\zipbarcode\hfil}} % % The \attn line if used. This is also set in the \envfont so % that everything will be consistant (except perhaps the return % address, but that should follow the format of the letterhead.) % This is put in a 0.25in \vbox, so that the barcode will be up 0.25 % in from the bottom of the envelope. \vbox to 0.25true in{\vfil\leftline{\envfont\enspace\Xattn}\vskip0.1true in} } % \vbox to 2.25true in \eject\end % not \bye, it has a \vfill in it --- % zip.tex % % J. Daniel Smith % 24 May 1990 % % Modified from a STY file snarfed from someplace else. But I don't % remember where the original code came from... OOPS!!! % % Make a barcode for a ZIP code! % % Example usage is below. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \catcode`@=11 % letter % % Dimensions of bars to be used in the barcode \newdimen\b@rwidth \newdimen\b@rlong \newdimen\b@rshort \newdimen\b@rsep \b@rwidth=0.02true in \b@rlong=0.125true in \b@rshort=0.05true in \b@rsep=0.0275true in \def\sb@r{\vrule height\b@rshort width\b@rwidth depth0pt \kern\b@rsep} \def\lb@r{\vrule height\b@rlong width\b@rwidth depth0pt \kern\b@rsep} % The barcodes for each digit \def\zerob@r{\lb@r\lb@r\sb@r\sb@r\sb@r} \def\oneb@r{\sb@r\sb@r\sb@r\lb@r\lb@r} \def\twob@r{\sb@r\sb@r\lb@r\sb@r\lb@r} \def\threeb@r{\sb@r\sb@r\lb@r\lb@r\sb@r} \def\fourb@r{\sb@r\lb@r\sb@r\sb@r\lb@r} \def\fiveb@r{\sb@r\lb@r\sb@r\lb@r\sb@r} \def\sixb@r{\sb@r\lb@r\lb@r\sb@r\sb@r} \def\sevenb@r{\lb@r\sb@r\sb@r\sb@r\lb@r} \def\eightb@r{\lb@r\sb@r\sb@r\lb@r\sb@r} \def\nineb@r{\lb@r\sb@r\lb@r\sb@r\sb@r} \newcount\zipb@rm \newcount\zipb@rn \chardef\ten=10 %Almost like using \ifcase... except `-' is ignored. \def\zipb@r@@@#1#2{\expandafter\def\csname zipb@r@@#1\endcsname% {#2\advance\zipb@rn#1\relax}} \newbox\zipbarcode \zipb@r@@@0{\global\setbox\zipbarcode\hbox{\box\zipbarcode\zerob@r}} \zipb@r@@@1{\global\setbox\zipbarcode\hbox{\box\zipbarcode\oneb@r}} \zipb@r@@@2{\global\setbox\zipbarcode\hbox{\box\zipbarcode\twob@r}} \zipb@r@@@3{\global\setbox\zipbarcode\hbox{\box\zipbarcode\threeb@r}} \zipb@r@@@4{\global\setbox\zipbarcode\hbox{\box\zipbarcode\fourb@r}} \zipb@r@@@5{\global\setbox\zipbarcode\hbox{\box\zipbarcode\fiveb@r}} \zipb@r@@@6{\global\setbox\zipbarcode\hbox{\box\zipbarcode\sixb@r}} \zipb@r@@@7{\global\setbox\zipbarcode\hbox{\box\zipbarcode\sevenb@r}} \zipb@r@@@8{\global\setbox\zipbarcode\hbox{\box\zipbarcode\eightb@r}} \zipb@r@@@9{\global\setbox\zipbarcode\hbox{\box\zipbarcode\nineb@r}} \def\zipb@r@@#1{\csname zipb@r@@#1\endcsname} \def\zipb@r@#1{\ifx#1\null \let\next\relax \else \zipb@r@@{#1}#1% \let\next\zipb@r@ \fi \next} \def\zipbar#1{\setbox\zipbarcode=\null \hbox{ % put numbers in an \hbox \global\setbox\zipbarcode\hbox{\box\zipbarcode\lb@r} % start with long bar \zipb@rn\z@\zipb@r@#1\null \zipb@rm\zipb@rn \divide\zipb@rm\ten \multiply\zipb@rm\ten \advance\zipb@rm-\zipb@rn \ifnum\zipb@rm<0 \advance\zipb@rm\ten \fi \zipb@r@@{\the\zipb@rm} % last digit, so that the sum is divisible by ten \global\setbox\zipbarcode\hbox{\box\zipbarcode\lb@r}% end with a long bar } % end of \hbox } \catcode`@=12 % disable private sequences %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %\zipbar{1234567890} % %\zipbar{48837} % %\zipbar{78653--0102} %\bye \endinput -- =========================================================================== J. Daniel Smith Internet: dsmith@applga.aa.cad.slb.com Schlumberger CAD/CAM BITNET: smithdan@msuegr Ann Arbor, Michigan Usenet: uunet!sharkey!applga!dsmith
dlv@CUNYVMS1.GC.CUNY.EDU (Dimitri Vulis) (02/27/91)
J. Daniel Smith said: >I played around with this about a year or so ago... (Someone posted >PostScript code to do this in comp.lang.postscript, and I wanted to >show it could be done in TeX, too). > >The following macro file is what I finally ended up with. If I >remember correctly, some of the code was snarfed from another .STY >file, but like a total idiot, I forgot to mention that in the STY >file at the time.... I wrote these Postnet bar code macros and posted them to TeXHAX a couple of years ago, and re-posted them to comp.mail.misc a few weeks ago, and I'd say "some of the code was snarfed" is a serious understatement. :) Anyway, I have since added a few bells and whistles to these macros (they now produce an FIM bar code as well and don't use \special's; you still need a device driver that'll print in landscape), and sent them to TUGBOAT a few weeks ago. By the way, starting this summer you'll be able to pay 27c instead of 29c for postage if your envelope has Postnet and FIM bars. Dimitri Vulis
xiaofei@acsu.buffalo.edu (Xiaofei Wang) (02/27/91)
In article <00944d2d.08e883e0.3751@CUNYVMS1.GC.CUNY.EDU> dlv@CUNYVMS1.GC.CUNY.EDU (Dimitri Vulis) writes:
* I wrote these Postnet bar code macros and posted them to TeXHAX a couple
* of years ago, and re-posted them to comp.mail.misc a few weeks ago, and
* I'd say "some of the code was snarfed" is a serious understatement. :)
I did not find the code from comp.mail.misc. If some one has it [newer
version] please post. I am sure that every one on this net would like to
save the precious two cents.
--
xiaofei@acsu.buffalo.edu / rutgers!ub!xiaofei / v118raqa@ubvms.bitnet