summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/cjw/cjw-env.cls
blob: 84460a22d694d50771dc44a338b27c79a7a3f2c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
%%-*- LaTeX -*-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% cjwenv.cls
%
%
% Class file for typesetting envelopes.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title:        cjwenv.cls
% Author:       Colin J. Wynne <cwynne@brutus.mts.jhu.edu>
% Date:         Tue Dec 31 13:10:56 1996
% Last Rev.:
%
% Usage:
%
% Here is an example:
%
% \documentclass[business,11pt]{cjwenv}
% \address{%
%   My Home Address	\\
%   Street Name		\\
%   City, ST  ZIP}
%
% \begin{document}
% \begin{envelope}[c]{%
%   Prof. Peter Schickele	\\
%   USND Hoopole		\\
%   Hoopole, ND  12345}
% \end{envelope}
% 
% \begin{envelope}{%
%   Dr. Seuss			\\
%   Whoville, ??  67890}
% \address[c]{%
%   Horton		\\
%   Lost		\\
%   Hoboken, NJ  13579}
% \end{envelope}
% 
% \end{document}

% Declare the file version and date.
\def\fileversion{1.1}
\def\filedate{1998/10/5}

% Identify the class.
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{cjw-env}%
  [\filedate\space v\fileversion\space Envelope Class---CJW]

% My printer puts the top of the landscape page on the opposite side
% of the printer from the envelope feed.  Therefore, we offer the
% option of putting the output at the bottom of a standard page.
\newif \if@atbottom	\@atbottomfalse

% We set an envelope type with the following macro.
\newcommand{\envtype}[1]{%
  \renewcommand{\do@envelope}{\csname env@#1\endcsname}}
\newcommand{\do@envelope}{}

% Class options:
%
%   For business envelopes.  Other types should be handled thusly.
\DeclareOption{business}{\envtype{business}}
%   For 6.5" business envelopes.
\DeclareOption{narrow}{\envtype{narrow}}
%   For bottom printing.
\DeclareOption{bottom}  {\@atbottomtrue}
% Default: pass to article.
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}

% Pick a default envelope type.
\ExecuteOptions{business}
\ProcessOptions

% Load primary class.
\LoadClass[12pt]{article}

% All we care about is hieght, width, and offsets.  Zero out
% everything else.
\newcommand{\reset@page}{%
  \setlength{\oddsidemargin}	{0.0pt}
  \setlength{\topmargin}		{0.0pt}
  \setlength{\headheight}		{0.0pt}
  \setlength{\headsep}			{0.0pt}
  \setlength{\marginparsep}		{0.0pt}
  \setlength{\marginparwidth}	{0.0pt}
  \setlength{\footskip}			{0.0pt}
    %
  \setlength{\parskip}			{0.0pt}
  \setlength{\parindent}		{0.0pt}
    %
  \setlength{\textwidth}		{\paperwidth}
    \addtolength{\textwidth}	{-1.0in}
  \setlength{\textheight}		{\paperheight}
    \addtolength{\textheight}	{-1.0in}
  }

% This is the business envelope code.
\newcommand{\env@business}{%
  % Introduce a postscript special for landscape printing.
  \special{landscape}
  % Swap the height and width in TeX to match the landscape orientation.
  \setlength{\@tempdima}	{\paperheight}
  \setlength{\paperheight}	{\paperwidth}
  \setlength{\paperwidth}	{\@tempdima}
  %
  % Our business envelope has physical height of 4.125", and we will
  % leave a half inch on either side as a margin.
  \setlength{\textheight}   { 3.125in}
    \setlength{\voffset}    {-0.500in}
  % For bottom printing:
  \if@atbottom
    % This calculates the \voffset necessary to put the *physical*
    % bottom off the envelope (half inch below printable area) flush
    % bottom on the physical (landscap) page.
    \setlength{\@tempdima}  {\paperheight}
    \addtolength{\@tempdima}{-1.0in}
    \setlength{\@tempdimb}  {\textheight}
    \addtolength{\@tempdimb}{-\voffset}
    \addtolength{\@tempdima}{-\@tempdimb}
      %
    \setlength{\voffset}    {\@tempdima}
  \fi
  % We leave 0.75" horizontal margin on either side of a 9.5"
  % envelope. 
  \setlength{\textwidth}    { 8.000in}
    \setlength{\hoffset}    {-0.250in}
  }

% For a narrow (3.625" x 6.5") business envelope. 
\newcommand{\env@narrow}{%
  % Introduce a postscript special for landscape printing.
  \special{landscape}
  % Swap the height and width in TeX to match the landscape orientation.
  \setlength{\@tempdima}	{\paperheight}
  \setlength{\paperheight}	{\paperwidth}
  \setlength{\paperwidth}	{\@tempdima}
  %
  % Our envelope has physical height of 3.625", and we will
  % leave a quarter inch on either side as a margin.
  \setlength{\textheight}   { 3.125in}
    \setlength{\voffset}    {-0.250in}
  % For bottom printing:
  \if@atbottom
    % This calculates the \voffset necessary to put the *physical*
    % bottom off the envelope (quarter inch below printable area)
    % flush bottom on the physical (landscap) page.
    \setlength	{\@tempdima}{\paperheight}
    \addtolength{\@tempdima}{-1.000in}
    \setlength	{\@tempdimb}{\textheight}
    \addtolength{\@tempdimb}{-\voffset}
    \addtolength{\@tempdima}{-\@tempdimb}
      %
    \setlength{\voffset}    {\@tempdima}
  \fi
  % We leave 0.5" horizontal margin on either side of a 6.5"
  % envelope. 
  \setlength{\textwidth}    { 5.50in}
    \setlength{\hoffset}    {-0.50in}
  }
 
% How the sender's address is input.  By default, it will be flush
% left/ragged right.  An appropriate optional argument may be given.
\newcommand{\address}[2][l]{%
  \gdef\@address{#2}\gdef\from@align{#1}}
\address{}

% This does the actual page setup at the end of the preamble.  It must
% be done here and not after the \begin{document} in order for all the
% page parameters to work out, it seems.
\AtBeginDocument{%
  \reset@page\do@envelope}

% The envelope environment sets the actual envelope.  Mandatory
% argument is the recipient's address.  Optional argument changes the
% alignment of that adress.  There should probably be nothing in the
% actual environemnt, though in printing numerous envelopes one could
% put different return addresses in, or perhaps additional typesetting
% commands.
\newenvironment{envelope}[2][l]%
  {\gdef\@recipient{#2}\gdef\recip@align{#1}}
  {\do@envelope\clearpage
   \thispagestyle{empty}
   \vtop to \textheight{
     \hbox{%
       \begin{tabular}{\from@align}
         \@address
       \end{tabular}}
     \vfill
     \hbox to \textwidth{\hss
       \begin{tabular}{\recip@align}
         \@recipient
       \end{tabular}\hss}
     \vfill}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%