| 1 |
% PROGRAMMER'S MANUAL in Plain TeX |
| 2 |
|
| 3 |
\input formlett.sty |
| 4 |
|
| 5 |
% FONTS |
| 6 |
\font\hbold=cmbx10 at 17.28pt |
| 7 |
\font\lbold=cmbx10 at 14.4pt |
| 8 |
\font\bbold=cmbx10 at 12pt |
| 9 |
\font\small=cmr8 |
| 10 |
\font\tiny=cmr5 |
| 11 |
\font\stt=cmtt9 |
| 12 |
\catcode`\@=11\relax |
| 13 |
% |
| 14 |
% |
| 15 |
% |
| 16 |
% OTHER MACROS |
| 17 |
% |
| 18 |
\catcode`\~=11\relax \def\t{{\tt ~}} |
| 19 |
\catcode`\~=\active\relax |
| 20 |
\catcode`\!=0\relax !catcode`!\=11!relax |
| 21 |
!def!esc{\}!def!escs{\! } |
| 22 |
!catcode`!\=0!relax \catcode`\!=12\relax |
| 23 |
\def\rqs{\rq\ } |
| 24 |
\def\LaTeX{{\rm L\kern-.36em\raise.3ex\hbox{\font\sc=cmcsc10\sc a}\kern-.15em |
| 25 |
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}} |
| 26 |
|
| 27 |
% makeshift macro |
| 28 |
\catcode`\^^M=13\relax% |
| 29 |
\def\setraw{\bgroup\rm@ligature\set@space\set@tab% |
| 30 |
\set@cr\stt\raw@chars[11][13][13][13][13]\def^^M{\strut\par}\setraw@@}% |
| 31 |
\edef\temp@macro{% |
| 32 |
\noexpand\long\noexpand\def\noexpand\setraw@@\noexpand##1^^M##2% |
| 33 |
\esc@ unsetraw{##1##2\noexpand\egroup}}\temp@macro % |
| 34 |
\catcode`\^^M=5\relax% |
| 35 |
|
| 36 |
|
| 37 |
\font\ninerm=cmr9 \font\eightrm=cmr8 |
| 38 |
\font\ninei=cmmi9 \font\eighti=cmmi8 |
| 39 |
\font\ninesy=cmsy9 \font\eightsy=cmsy8 |
| 40 |
\font\ninebf=cmbx9 \font\eightbf=cmbx8 |
| 41 |
\font\ninett=cmtt9 \font\eighttt=cmtt8 |
| 42 |
\font\nineit=cmti9 \font\eightit=cmti8 |
| 43 |
\font\ninesl=cmsl9 \font\eightsl=cmsl8 |
| 44 |
|
| 45 |
\font\sixrm=cmr6 |
| 46 |
\font\sixi=cmmi6 |
| 47 |
\font\sixsy=cmsy6 |
| 48 |
\font\sixbf=cmbx6 |
| 49 |
|
| 50 |
\skewchar\ninei='177 \skewchar\eighti='177 \skewchar\sixi='177 |
| 51 |
\skewchar\ninesy='60 \skewchar\eightsy='60 \skewchar\sixsy='60 |
| 52 |
\hyphenchar\ninett=-1 \hyphenchar\eighttt=-1 \hyphenchar\tentt=-1 |
| 53 |
|
| 54 |
\font\tentex=cmtex10 |
| 55 |
\font\inchhigh=cminch |
| 56 |
\font\titlefont=cmssdc10 at 40pt % titles in chapter openings |
| 57 |
\font\eightss=cmssq8 % quotations in chapter closings |
| 58 |
\font\eightssi=cmssqi8 % ditto, slanted |
| 59 |
\font\tenu=cmu10 % unslanted te~t italic |
| 60 |
\font\manual=manfnt % METAFONT logo and special symbols |
| 61 |
\font\magnifiedfiverm=cmr5 at 10pt % to demonstrate magnification |
| 62 |
|
| 63 |
\newskip\ttglue |
| 64 |
\def\eightpoint{\def\rm{\fam0\eightrm}% switch to 8-point type |
| 65 |
\textfont0=\eightrm \scriptfont0=\sixrm \scriptscriptfont0=\fiverm |
| 66 |
\textfont1=\eighti \scriptfont1=\sixi \scriptscriptfont1=\fivei |
| 67 |
\textfont2=\eightsy \scriptfont2=\sixsy \scriptscriptfont2=\fivesy |
| 68 |
\textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex |
| 69 |
\textfont\itfam=\eightit \def\it{\fam\itfam\eightit}% |
| 70 |
\textfont\slfam=\eightsl \def\sl{\fam\slfam\eightsl}% |
| 71 |
\textfont\ttfam=\eighttt \def\tt{\fam\ttfam\eighttt}% |
| 72 |
\textfont\bffam=\eightbf \scriptfont\bffam=\sixbf |
| 73 |
\scriptscriptfont\bffam=\fivebf \def\bf{\fam\bffam\eightbf}%, |
| 74 |
\tt \ttglue=.5em plus.25em minus.15em |
| 75 |
\normalbaselineskip=9pt |
| 76 |
\setbox\strutbox=\hbox{\vrule height7pt depth2pt width0pt}% |
| 77 |
\let\sc=\sixrm \let\big=\eightbig \normalbaselines\rm} |
| 78 |
|
| 79 |
|
| 80 |
%%%%%%%%%%%%%%%% |
| 81 |
%%%%%%%%%%%%%%%% |
| 82 |
% |
| 83 |
% END OF EXTRA MACROS AND FONTS |
| 84 |
% |
| 85 |
%%%%%%%%%%%%%%%% |
| 86 |
%%%%%%%%%%%%%%%% |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
\message{<<document for programmers>>} |
| 91 |
\catcode`\@=11\relax |
| 92 |
\PAGENO=1 |
| 93 |
\voffset=-0.3in |
| 94 |
|
| 95 |
|
| 96 |
\ifx\pageno\undefined |
| 97 |
\errmessage{Please run TeX if you want this article on how to use |
| 98 |
<formlett.sty> to be processed as well!} |
| 99 |
\fi |
| 100 |
|
| 101 |
|
| 102 |
\parindent=0pt |
| 103 |
\hsize=469.75499pt % the default |
| 104 |
\vsize=9.6in %8.83in |
| 105 |
%\vsize=8.83in |
| 106 |
|
| 107 |
\def\makefootline{\baselineskip=24pt \line{\the\footline}} |
| 108 |
\footline={\lower5pt |
| 109 |
\hbox to \hsize |
| 110 |
{{\tenrm Jiang Z ~~~{\tensl Formlett: ~for letters to multiple receivers} |
| 111 |
\hss \folio}}} |
| 112 |
|
| 113 |
\leftline{\hbold FORMLETT: ~~~for Letters to Multiple Receivers} |
| 114 |
\bigskip |
| 115 |
|
| 116 |
|
| 117 |
{\advance\leftskip by13mm \overfullrule=0pt |
| 118 |
\advance\rightskip by 20mm %28mm |
| 119 |
\sl |
| 120 |
\noindent Zhuhan JIANG\par |
| 121 |
\noindent School of Computing and Information Technology, |
| 122 |
University of Western Sydney, Victoria Road, Parramatta NSW 2150, Australia. |
| 123 |
{\sl ~~Email}:[email protected]\par |
| 124 |
\medskip |
| 125 |
\rm\smooth |
| 126 |
\noindent (Last updated on 26 May 2003)\par |
| 127 |
\medskip |
| 128 |
|
| 129 |
\noindent |
| 130 |
In this article, the author explains how to use a form-letter |
| 131 |
style {\tt formlett.sty}, designed for plain \TeX\ and \LaTeX |
| 132 |
\ or \LaTeX2e. {\tt formlett.sty} supports different parameter input |
| 133 |
methods, parameter naming and defaulting mechanism, as well as |
| 134 |
facilities for previewing parameter positions and printing |
| 135 |
labels. It is written for the purpose of being powerful, robust |
| 136 |
and above all easy to use.\par } |
| 137 |
|
| 138 |
|
| 139 |
\begincolumns |
| 140 |
|
| 141 |
{\lbold Introduction} |
| 142 |
|
| 143 |
\smallskip |
| 144 |
|
| 145 |
In this modern world of ours, we often need to send a set of form |
| 146 |
letters, personalised or non-personalised, to many receivers at |
| 147 |
the same time. Or perhaps we would like to have a collection of |
| 148 |
business letters or information brochures which we would like to |
| 149 |
call upon {\sl instantly} whenever we need them. |
| 150 |
|
| 151 |
\medskip |
| 152 |
|
| 153 |
Our purpose here is therefore to describe a comprehensive |
| 154 |
implementation of such a macro system, handling form letters |
| 155 |
under \TeX\ or \LaTeX. The main objective is to provide an easy |
| 156 |
way to output many form letters with their own parameters, with |
| 157 |
or without the use of multiple files. There will be a coherent |
| 158 |
and simple format for putting parameters inside a form letter, |
| 159 |
with a number of helping facilities for such as naming parameters |
| 160 |
and previewing their positions. A minimum support for printing |
| 161 |
mailing labels is also provided. |
| 162 |
|
| 163 |
|
| 164 |
\medskip |
| 165 |
|
| 166 |
The concept of macros [1] for form letters is not new: there |
| 167 |
already exist macros in this connection such as {\tt merge}, {\tt |
| 168 |
textmerg} and {\tt address} to name a few, see [2,3] for further |
| 169 |
details. Our stress here is therefore laid on the ease to use, |
| 170 |
along with the power and the robustness of the macros. |
| 171 |
|
| 172 |
\bigskip |
| 173 |
{\lbold Format} |
| 174 |
|
| 175 |
\smallskip |
| 176 |
|
| 177 |
In this section, we always assume that the file {\tt formlett.sty} |
| 178 |
or {\tt formlett.tex} of version {\tt 2.3} has |
| 179 |
already been input. Certain version of {\tt formlett.sty} can be |
| 180 |
obtained via anonymous ftp from CTAN sites at |
| 181 |
{\tt macros /generic}. |
| 182 |
|
| 183 |
\medskip |
| 184 |
|
| 185 |
Essentially, each form letter, or letter format or letter |
| 186 |
template, will be included between {\tt \string\beginletter} and |
| 187 |
{\tt \string\endletter}. Letter parameters that will be specified |
| 188 |
later on for each particular letter can be given by {\tt |
| 189 |
\string\paras[<m>][<n>]}, representing the {\tt <m>}-th parameter |
| 190 |
of the {\tt<n>}-the parameter group, at the positions you want |
| 191 |
them to be. Let a cluster denote a complete collection of |
| 192 |
parameters that may be specified for a form letter. Then we can |
| 193 |
specify letter parameters group by group for a cluster such that |
| 194 |
inside each group the parameters are given {\sl sequentially} and |
| 195 |
a termination of one group should not affect the |
| 196 |
resynchronisation for the next group. For instance we can keep |
| 197 |
the address of a receiver as a single group, as it often contains |
| 198 |
different number of (parameter) lines. |
| 199 |
|
| 200 |
|
| 201 |
\medskip |
| 202 |
We often want to treat a particular group of letter |
| 203 |
parameters somewhat uniformly. This can be achieved by one of the |
| 204 |
following commands |
| 205 |
|
| 206 |
\setraw |
| 207 |
\blockparas[<m>][<n>][<pre>][<post>] |
| 208 |
\addressparas[<m>][<n>][<width>][<indent>] |
| 209 |
\unsetraw |
| 210 |
|
| 211 |
They represent parameters in the {\tt<n>}-th group, from the {\tt |
| 212 |
<m>}-th to the last parameter of that group. For {\tt |
| 213 |
\string\blockparas}, tokens {\tt <pre>} and {\tt <post>} are |
| 214 |
those to be added in front and behind respectively each of the |
| 215 |
legitimate parameters mentioned above. If {\tt <post>} is |
| 216 |
{\tt\string\relax}, it will then not be appended at the end. |
| 217 |
Instead, each chosen parameter will be put into a {\tt $\{\}$}- |
| 218 |
pair before preceded by the token {\tt <pre>}. The reason for |
| 219 |
this exception is that while {\tt <pre> and <post>} are meant to |
| 220 |
be the front and end macros for each selected parameter, in the |
| 221 |
case of {\tt <post>} being {\tt \string\relax}, we may regard |
| 222 |
{\tt<pre>} as {\sl acting upon} each chosen parameter. |
| 223 |
|
| 224 |
|
| 225 |
\medskip |
| 226 |
The command {\tt \string\addressparas}, however, uses |
| 227 |
{\tt \string\blockparas} indirectly and will put the chosen |
| 228 |
parameters into a box of width {\tt<width>}. If any selected |
| 229 |
parameter is longer than {\tt<width>}, then the line will be |
| 230 |
wrapped around, with all wrapped potions being indented by an |
| 231 |
{\tt<indent>}. This may be used to deal with very long address |
| 232 |
lines. Incidentally, we may use {\tt \string\textbox} or {\tt |
| 233 |
\string\addressbox} or {\tt \string\ADDRESSBOX} to control the |
| 234 |
width of a single parameter. The general format reads |
| 235 |
|
| 236 |
|
| 237 |
\setraw |
| 238 |
\textbox[<width]{<materials>} |
| 239 |
\addressbox[<width>][<indent>]{<materials>} |
| 240 |
\ADDRESSBOX{<width>}{<indent>}{<materials>} |
| 241 |
\unsetraw |
| 242 |
|
| 243 |
where the meaning of the macro parameters are self-explanatory. |
| 244 |
|
| 245 |
|
| 246 |
\medskip |
| 247 |
|
| 248 |
For the macro parameters, we have for convenience provided the |
| 249 |
following defaults for those in the squared brackets |
| 250 |
|
| 251 |
\setraw |
| 252 |
<m>=1 |
| 253 |
<n>=1 |
| 254 |
<pre>=\noindent |
| 255 |
<post>=\par |
| 256 |
<width>= 8truecm |
| 257 |
<indent>= 1.5em |
| 258 |
\unsetraw |
| 259 |
|
| 260 |
This way, for instance, {\tt\string\paras[1][1]} is equivalent |
| 261 |
to any of the following commands |
| 262 |
|
| 263 |
\setraw |
| 264 |
\paras, \paras[1], \paras[][1], |
| 265 |
\paras[1][], \paras[][] |
| 266 |
\unsetraw |
| 267 |
|
| 268 |
and the following three commands are also the same |
| 269 |
|
| 270 |
\setraw |
| 271 |
\addressbox{one address line} |
| 272 |
\addressbox[8truecm]{one address line} |
| 273 |
\addressbox[][1.5em]{one address line} |
| 274 |
\unsetraw |
| 275 |
|
| 276 |
|
| 277 |
\medskip |
| 278 |
|
| 279 |
Incidentally this is the reason why we used the second parameter |
| 280 |
{\tt<n>} to represent the group number: the defaults can often be |
| 281 |
dropped off more frequently. By default, all letter parameters |
| 282 |
specified will be put into a group environment before putting |
| 283 |
them into the form letter, unless {\tt \string\localparasfalse} |
| 284 |
is issued beforehand. |
| 285 |
|
| 286 |
\medskip |
| 287 |
To output a new letter entity, i.e a complete letter, |
| 288 |
we may use |
| 289 |
|
| 290 |
|
| 291 |
\setraw |
| 292 |
\moreletter |
| 293 |
para-1-1;para-1-2;para-1-3; ... |
| 294 |
+para-2-1;para-2-2;... |
| 295 |
+ ... |
| 296 |
+para-n-1;para-n-2; ... ;para-n-m ! |
| 297 |
\unsetraw |
| 298 |
|
| 299 |
|
| 300 |
where \lq{\tt ;}\rqs separate parameters inside a same group, |
| 301 |
\lq{\tt +}\rqs separates groups, \lq{\tt !}\rqs ends a cluster of |
| 302 |
parameters, and \lq{\tt ...}\rqs represent further letter |
| 303 |
parameters. These three tokens are nothing special: we may change |
| 304 |
them to for instance \lq{\tt ....}\rq, \lq{\tt ----}\rqs and |
| 305 |
\lq{\tt ====}\rqs respectively by {\tt \string\blockmarks}, and |
| 306 |
change them back to \lq{\tt ; + !}\rqs by {\tt |
| 307 |
\string\defaultmarks}. For more general case, use |
| 308 |
|
| 309 |
\setraw |
| 310 |
\delimiters{<A>}{<B>}{<C>} |
| 311 |
\unsetraw |
| 312 |
|
| 313 |
where {\tt <A>}, {\tt <B>} and {\tt <C>} are the new toks |
| 314 |
replacing \lq{\tt ; + !}\rqs respectively. If we have to use |
| 315 |
these three special characters or tokens inside our {\sl letter |
| 316 |
parameters}, then use {\tt \string\pstr}, {\tt\string\gstr} and |
| 317 |
{\tt\string\cstr} respectively instead. |
| 318 |
|
| 319 |
\medskip |
| 320 |
|
| 321 |
For the case of many clusters, we may enclose them, separated by |
| 322 |
any white spaces or empty lines, between {\tt |
| 323 |
\string\beginpilemode} and {\tt \string\endpilemode} so that we |
| 324 |
don't have to put {\tt \string\moreletter} in front of each |
| 325 |
cluster of parameters. |
| 326 |
|
| 327 |
|
| 328 |
\medskip |
| 329 |
We may also enter letter parameters line by line. In other words, |
| 330 |
we may essentially replace \lq{\tt;}\rqs in the {\tt |
| 331 |
\string\moreletter} format by a normal line break. In this case, |
| 332 |
we shall put clusters of parameters between {\tt |
| 333 |
\string\beginblockmode} and {\tt \string\endblockmode}. Thus the |
| 334 |
following commands |
| 335 |
|
| 336 |
|
| 337 |
\setraw |
| 338 |
\beginblockmode |
| 339 |
<para-1-1> |
| 340 |
<para-1-2> |
| 341 |
+ letter one |
| 342 |
|
| 343 |
<para-2-2> |
| 344 |
! |
| 345 |
|
| 346 |
<addr-1-1> |
| 347 |
<addr-1-2> |
| 348 |
! letter two |
| 349 |
\endblockmode |
| 350 |
\unsetraw |
| 351 |
|
| 352 |
|
| 353 |
will produce the required form letter for each cluster of |
| 354 |
parameters. The general rules are as follows: |
| 355 |
|
| 356 |
{\parindent=1.5em |
| 357 |
\item{$\bullet$} If a line contains {\tt \string\endblockmode} or {\tt !} |
| 358 |
or {\tt +}, then everything else on that line is ignored and that |
| 359 |
line serves as an end/cluster/group marking line in the given |
| 360 |
priority order. |
| 361 |
|
| 362 |
\item{$\bullet$} Leading and trailing empty lines before or after |
| 363 |
a complete cluster will be ignored, unless \lq{\tt ;}\rqs is |
| 364 |
there to force the next (empty) line as a starting parameter. |
| 365 |
\par } |
| 366 |
|
| 367 |
Obviously {\tt \string\blockmarks} provides a more sensible |
| 368 |
delimiters for the {\tt blockmode}, under which we could have |
| 369 |
|
| 370 |
\setraw |
| 371 |
\blockmarks\beginblockmode |
| 372 |
....... force next empty line active |
| 373 |
|
| 374 |
<para-1-2> |
| 375 |
------- - mark end of 1st group |
| 376 |
|
| 377 |
<para-2-2> |
| 378 |
<para-2-3> |
| 379 |
======== end of cluster |
| 380 |
|
| 381 |
<other clusters> |
| 382 |
\endblockmode |
| 383 |
\unsetraw |
| 384 |
|
| 385 |
\medskip |
| 386 |
A simpler and perhaps more often encountered scenario is |
| 387 |
to use names and addresses only. In this case, there will be |
| 388 |
essentially only {\sl one} group of parameters for each cluster. |
| 389 |
Thus we may use empty lines to delimit the clusters, and use line |
| 390 |
by line mode for the individual parameters. This way, each |
| 391 |
block of consecutive nonempty lines in |
| 392 |
|
| 393 |
\setraw |
| 394 |
\beginlinemode |
| 395 |
<name-1> |
| 396 |
<address-1-1> |
| 397 |
<address-1-2> |
| 398 |
|
| 399 |
<name-2> |
| 400 |
<1st part of addr-2-1> % |
| 401 |
<continued part of line addr-2-1> |
| 402 |
|
| 403 |
<name-3> % letter three |
| 404 |
\endlinemode |
| 405 |
\unsetraw |
| 406 |
|
| 407 |
|
| 408 |
will output a new complete letter, corresponding to the specified |
| 409 |
letter parameters. |
| 410 |
|
| 411 |
|
| 412 |
\medskip |
| 413 |
{\smooth |
| 414 |
Ideally, the name--address entries will be produced by a database |
| 415 |
utility. Since they often contain special characters such as \lq |
| 416 |
{\tt \#}\rqs and \lq{\tt \$}\rqs explicitly, we may wish to |
| 417 |
change such characters in the parameters to the normal printable |
| 418 |
ones. For this purpose, we could use correspondingly the pair |
| 419 |
{\tt \string\beginrawblockmode$\{$<token>$\}$} with {\tt |
| 420 |
\string\endrawblockmode} or the pair {\tt |
| 421 |
\string\beginrawlinemode$\{$<token>$\}$} with {\tt |
| 422 |
\string\endrawlinemode}. If {\tt <token>} is not empty, then we |
| 423 |
use {\tt <token>} in place of {\tt \string\endrawblockmode} or |
| 424 |
{\tt \string\endrawlinemode}. In other words, {\tt <token>} is |
| 425 |
the password to leave the raw text mode. Since database utility |
| 426 |
will in general produce a {\sl fixed} number of {\tt <m>} lines |
| 427 |
for each cluster of parameters, we may use {\tt |
| 428 |
\string\begindatamode[<token>]$\{$<m>$\}$} and {\tt |
| 429 |
\string\enddatamode} (or {\tt<token>}) in place of {\tt |
| 430 |
\string\beginrawlinemode} and {\tt\string\endrawlinemode} so that |
| 431 |
each {\tt<m>} raw text lines, including the empty ones, will eject |
| 432 |
a form letter. |
| 433 |
} |
| 434 |
|
| 435 |
|
| 436 |
\medskip |
| 437 |
|
| 438 |
It is often desirable that a letter form or format and the actual |
| 439 |
parameters be kept in different files: it will help in archiving |
| 440 |
and retrieving form letters. Furthermore, if a letter is quite |
| 441 |
long such that the \TeX\ can't hold it in the memory, then we |
| 442 |
{\sl have to} keep the letter content in a separate file. |
| 443 |
Essentially we need to save everything between |
| 444 |
{\tt\string\beginletter} and {\tt \string\endletter} into a |
| 445 |
separate file, say, {\tt letter.let}, then later on use |
| 446 |
{\tt\string\inputletter$\{$letter.let$\}$} to load in the letter |
| 447 |
format. Should one prefer to keep everything inside a {\sl single} |
| 448 |
file, however, he may use {\tt\string\beginfile [{\it |
| 449 |
password}]$\{${\it file.ext}$\}$} and {\tt\string\endfile} (or |
| 450 |
{\it password}) to create files such as {\tt letter.let} |
| 451 |
mentioned above as a temporary scratch file. We note that {\tt |
| 452 |
letter.let} will not contain {\tt\string\beginletter} and |
| 453 |
{\tt\string\endletter} as {\tt \string\inputletter} will add them |
| 454 |
properly for us. Also the extension {\tt .let} is preferred in |
| 455 |
this connection as it can indicate that this type of format file |
| 456 |
should not quite be regarded as the normal \TeX\ files. |
| 457 |
|
| 458 |
\medskip |
| 459 |
|
| 460 |
Likewise, it is also desirable to have a separate address or |
| 461 |
general letter parameter file. For the address file, we remark |
| 462 |
that we have to keep the pairing {\tt \string\beginlinemode} with |
| 463 |
{\tt \string\endlinemode} or {\tt\string\beginblockmode} with |
| 464 |
{\tt \string\endblockmode} inside the address file, if we are to |
| 465 |
use any of them for some content of that file. Moreover, an |
| 466 |
extension {\tt .adr} is recommended for such files. Thus for a |
| 467 |
letter format or template saved in {\tt letter.let}, we may |
| 468 |
choose {\tt letter.adr} as the name for the related address file. |
| 469 |
|
| 470 |
\medskip |
| 471 |
After a letter format is completed for sometime, one may have |
| 472 |
difficulty in recalling what those parameters should refer to |
| 473 |
when using the form letter again. For this purpose, we provide |
| 474 |
a simple mechanism with {\tt\string\paranames} and {\tt |
| 475 |
\string\showparas}. To be more precise, if one puts {\tt |
| 476 |
\string\paranames\ name-1-1; ...; <etc>!} at the very beginning of |
| 477 |
the letter format, then one can use {\tt\string\showparas} |
| 478 |
outside to output a letter with its parameters replaced by their |
| 479 |
names. |
| 480 |
|
| 481 |
\medskip |
| 482 |
|
| 483 |
An alternative way, or rather a way of highlighting the positions |
| 484 |
of the letter parameters is to use {\tt\string\preview}. Under |
| 485 |
{\tt\string\preview}, or {\tt \string\previewtrue}, all |
| 486 |
parameters given by {\tt\string\paras[<m>][<n>]} will be boxed |
| 487 |
with double borderlines, similar to {\tt \previewtrue |
| 488 |
\paras[3][2]}, the number {\tt<n>-<m>} inside (corresponding to |
| 489 |
{\tt 2-3} in the shown box) denotes the {\tt<m>}-th parameter of |
| 490 |
the {\tt <n>}-th group. However, the parameters given by |
| 491 |
{\tt\string\blockparas} or {\tt\string\addressparas} will be |
| 492 |
boxed with triple borderlines. Moreover, the macro parameters |
| 493 |
{\tt<pre>} and {\tt <post>} will also be displayed explicitly. |
| 494 |
Since {\tt\string\addressparas} is essentially a special way of |
| 495 |
using {\tt\string\blockparas}, it is highlighted via that for the |
| 496 |
{\tt\string\blockparas}. In particular, |
| 497 |
{\tt\string\blockparas[3][6][\string\x][\string\y]} for instance |
| 498 |
will display under {\tt \string\preview} the following box |
| 499 |
|
| 500 |
\smallskip |
| 501 |
{\previewtrue \blockparas[3][6][\x][\y]} |
| 502 |
|
| 503 |
|
| 504 |
\medskip |
| 505 |
|
| 506 |
Sometimes we may want to have each given {\sl empty} letter |
| 507 |
parameter automatically replaced by a particular {\sl default} |
| 508 |
parameter. This can be easily done by using {\tt |
| 509 |
\string\loaddefaultparas} inside your letter format, i.e. |
| 510 |
essentially between {\tt \string\beginletter} and {\tt |
| 511 |
\string\endletter}, before any calling of the letter parameters |
| 512 |
via {\tt \string\paras} etc. Of course, the effect of {\tt |
| 513 |
\string\loaddefaultparas} is nil unless a command {\tt |
| 514 |
\string\paradefaults} is issued inside or (better still) outside |
| 515 |
the letter format. We note that {\tt \string\paradefaults} takes |
| 516 |
the macro parameters in the exact way as {\tt \string\paranames} |
| 517 |
does. One note of caution: {\tt \string\paradefaults} and {\tt |
| 518 |
\string\paranames} always use the default delimiters \lq{\tt ; + |
| 519 |
!}\rqs no matter how you changed them via {\tt |
| 520 |
\string\delimiters}. This is to avoid unnecessary complications. |
| 521 |
|
| 522 |
\medskip |
| 523 |
|
| 524 |
We note that printing labels is no more than designing a special |
| 525 |
letter template. The mechanism provided in {\tt formlett} however |
| 526 |
is to pick a subblock of parameters as the address. Basically all |
| 527 |
the form letter output inside {\tt\string\beginlabels} and |
| 528 |
{\tt\string\endlabels} will produce labels instead, taking the |
| 529 |
first parameter group as the address by default (see Appendix for |
| 530 |
more details). Incidentally, labels can be printed in single or |
| 531 |
double columns depending upon the choice of label width. |
| 532 |
|
| 533 |
\medskip |
| 534 |
|
| 535 |
To conclude this section, we remark that if you want to put {\tt |
| 536 |
\string\input\ {\sl filename} } into a letter parameter, make |
| 537 |
sure that there is a {\sl nontrivial} space following the {\sl |
| 538 |
filename}. To be on the safe side, always use {\tt |
| 539 |
\string\inputfile $\{$\sl filename.ext$\}$} instead. Also {\tt |
| 540 |
<!>}, when output to screen, is an invitation to read the log |
| 541 |
file for a warning message. |
| 542 |
|
| 543 |
\bigskip |
| 544 |
{\lbold Example} |
| 545 |
|
| 546 |
|
| 547 |
\smallskip |
| 548 |
|
| 549 |
The following is an example. If you are running plain \TeX, add |
| 550 |
{\tt\string\input\ formlett} at the top. But if you are running |
| 551 |
\LaTeX, then just add at the top the line |
| 552 |
|
| 553 |
\linecount=1\relax |
| 554 |
\stt\beginrawlist[][][4][][][3.3in]{} |
| 555 |
\documentstyle[formlett]{article} |
| 556 |
\begin{document} |
| 557 |
\endrawlist |
| 558 |
\rm |
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
The line numbering on the right hand side is for reference only, |
| 563 |
as in the other occurrences later on. The example reads as |
| 564 |
follows. |
| 565 |
|
| 566 |
\medskip |
| 567 |
|
| 568 |
\stt\beginrawlist[][][4][][][3.3in]{} |
| 569 |
\beginletter |
| 570 |
\paranames % optional |
| 571 |
\tt<<FULL NAME>>;% |
| 572 |
\tt<<ADDRESS-etc>>;% |
| 573 |
+\tt<<GIVEN NAME>>;% |
| 574 |
\tt<<MISSING ITEM>>;% |
| 575 |
\tt<<PHONE NUMBER>>! |
| 576 |
\loaddefaultparas % optional |
| 577 |
|
| 578 |
\NOPAGENUMBERS\parindent=0pt |
| 579 |
\noindent{\it\paras[1]}\par |
| 580 |
\blockparas[2]\par\bigskip |
| 581 |
|
| 582 |
Dear \paras[1][2],\par\medskip |
| 583 |
We have been looking for |
| 584 |
\paras[2][2] for quite a while |
| 585 |
without any luck, could you help |
| 586 |
us out? If so, please ring |
| 587 |
\paras[3][2]. \par\medskip |
| 588 |
Cheers!\hfill Michael\vfill\eject |
| 589 |
\endletter |
| 590 |
\preview \showparas |
| 591 |
\endrawlist |
| 592 |
\rm |
| 593 |
|
| 594 |
|
| 595 |
\medskip |
| 596 |
|
| 597 |
%%%%%%%%%%%% |
| 598 |
% letter top |
| 599 |
%%%%%%%%%%%% |
| 600 |
|
| 601 |
\beginletter |
| 602 |
\sl |
| 603 |
\hsize=3.1in\relax |
| 604 |
\medskip |
| 605 |
\paranames % optional |
| 606 |
\tt<<FULL NAME>>;% |
| 607 |
\tt<<ADDRESS-etc>>;% |
| 608 |
+\tt<<GIVEN NAME>>;% |
| 609 |
\tt<<MISSING ITEM>>;% |
| 610 |
\tt<<PHONE NUMBER>>! |
| 611 |
\loaddefaultparas % optional |
| 612 |
|
| 613 |
\NOPAGENUMBERS\parindent=0pt\overfullrule=0pt |
| 614 |
\noindent{\it\paras[1]}\par |
| 615 |
\blockparas[2]\par\medskip |
| 616 |
|
| 617 |
Dear \paras[1][2], |
| 618 |
|
| 619 |
\smallskip |
| 620 |
We have been looking for |
| 621 |
\paras[2][2] for quite a while |
| 622 |
without any luck, could you help |
| 623 |
us out? If so, please ring |
| 624 |
\paras[3][2]. \par\medskip |
| 625 |
Cheers!\hfill Michael\par %\vfill\eject |
| 626 |
\medskip |
| 627 |
\endletter |
| 628 |
|
| 629 |
%%%%%%%%%%%% |
| 630 |
% letter end |
| 631 |
%%%%%%%%%%%% |
| 632 |
|
| 633 |
|
| 634 |
The above is a typical letter format or form letter. Command |
| 635 |
{\tt\string\preview} in the last line gives |
| 636 |
|
| 637 |
{\preview} |
| 638 |
|
| 639 |
and, the name of the parameters are displayed via |
| 640 |
{\tt\string\showparas} as follows |
| 641 |
|
| 642 |
\showparas |
| 643 |
|
| 644 |
|
| 645 |
\medskip |
| 646 |
|
| 647 |
In other words, we can have a good understanding about what a |
| 648 |
letter format does {\sl without} reading its source code, which |
| 649 |
will be very handy for archiving and retrieving letter templates. |
| 650 |
To provide defaults for letter parameters and output new letters |
| 651 |
via {\tt blockmode}, we may add \par |
| 652 |
|
| 653 |
\medskip |
| 654 |
\stt\beginrawlist[][][4][][][3.3in]{} |
| 655 |
\paradefaults % optional |
| 656 |
To whom this may concern |
| 657 |
+Sir or Madam;something;% |
| 658 |
061-225-9905! |
| 659 |
|
| 660 |
\blockmarks |
| 661 |
\beginrawblockmode{} |
| 662 |
|
| 663 |
Mrs L Stenson |
| 664 |
#1-20 Sunset Street |
| 665 |
Hillside, Norway |
| 666 |
------ |
| 667 |
Louise |
| 668 |
a Bible |
| 669 |
220-8888 |
| 670 |
========= |
| 671 |
|
| 672 |
...... |
| 673 |
|
| 674 |
Above empty line active |
| 675 |
|
| 676 |
\endrawblockmode |
| 677 |
\endrawlist |
| 678 |
\rm |
| 679 |
|
| 680 |
%%%%%%%%%%%% |
| 681 |
% 1st letter top |
| 682 |
%%%%%%%%%%%% |
| 683 |
\paradefaults % optional |
| 684 |
To whom this may concern |
| 685 |
+Sir or Madam;something;% |
| 686 |
061-225-9905! |
| 687 |
|
| 688 |
%%%%%%%%%%%% |
| 689 |
% 1st letter end |
| 690 |
%%%%%%%%%%%% |
| 691 |
|
| 692 |
\medskip |
| 693 |
We note the parameters contain special characters \#. That is |
| 694 |
the reason why we used {\tt\string\beginrawblockmode}. Now |
| 695 |
suppose we have to wrap a very long address line, we could use |
| 696 |
{\tt \string\addressbox} to control an {\sl individual} |
| 697 |
parameter. The following is a typical case |
| 698 |
|
| 699 |
\medskip |
| 700 |
\stt\beginrawlist[][][4][][][3.3in]{} |
| 701 |
\defaultmarks |
| 702 |
\moreletter |
| 703 |
S Wales,;% |
| 704 |
\addressbox[2in][1em]{% |
| 705 |
University of Manchester Institute |
| 706 |
of Science and Technology, This is |
| 707 |
a long address line: it will be |
| 708 |
wrapped up automatically.}% |
| 709 |
+;a \TeX\ package \gstr\ manual and |
| 710 |
many more (\cstr)! |
| 711 |
\endrawlist |
| 712 |
\rm |
| 713 |
|
| 714 |
\medskip |
| 715 |
which is manifested in the following output |
| 716 |
|
| 717 |
%%%%%%%%%%%% |
| 718 |
% 2nd letter top |
| 719 |
%%%%%%%%%%%% |
| 720 |
\defaultmarks |
| 721 |
\moreletter |
| 722 |
S Wales,;% |
| 723 |
\addressbox[2in][1em]{% |
| 724 |
University of Manchester Institute |
| 725 |
of Science and Technology, This is |
| 726 |
a long address line: it will be |
| 727 |
wrapped up automatically.}% |
| 728 |
+;a \TeX\ package \gstr\ manual and |
| 729 |
many more (\cstr)! |
| 730 |
%%%%%%%%%%%% |
| 731 |
% 2nd letter end |
| 732 |
%%%%%%%%%%%% |
| 733 |
|
| 734 |
|
| 735 |
\medskip |
| 736 |
|
| 737 |
Please note that the default parameters have been used there. In |
| 738 |
the case of putting {\sl only} name and address into a form |
| 739 |
letter, we may typically use {\tt linemode} via e.g. |
| 740 |
|
| 741 |
\medskip |
| 742 |
\stt\beginrawlist[][][4][][][3.3in]{} |
| 743 |
\beginlinemode |
| 744 |
Z Jiang |
| 745 |
UNE, Arimdale |
| 746 |
|
| 747 |
T Ribbons |
| 748 |
UMIST, Manchester |
| 749 |
\endlinemode |
| 750 |
\end{document} |
| 751 |
\endrawlist |
| 752 |
\rm |
| 753 |
|
| 754 |
\medskip |
| 755 |
|
| 756 |
If one saves lines 4-22 to file {\tt myletter.let}, lines 25-63 |
| 757 |
or simply lines 57-63 to file {\tt myletter.adr}, then we can for |
| 758 |
instance produce via \LaTeX\ the form letter for multiple |
| 759 |
receivers by |
| 760 |
|
| 761 |
\setraw |
| 762 |
\documentstyle[formlett]{article} |
| 763 |
\begin{document} |
| 764 |
\inputletter{myletter.let} |
| 765 |
\showparas \preview |
| 766 |
\paradefaults To whom it may concern! |
| 767 |
\inputfile{myletter.adr} |
| 768 |
\beginlabels % 1st parameter group as address |
| 769 |
\inputfile{myletter.adr} % for labels |
| 770 |
\endlabels |
| 771 |
\end{document} |
| 772 |
\unsetraw |
| 773 |
|
| 774 |
{\smooth |
| 775 |
|
| 776 |
If one puts commands {\tt\string\beginlables} and |
| 777 |
{\tt\string\endlabels} at e.g. immediately after line 2 and 63 |
| 778 |
respectively, then one gets all the posting labels instead. If |
| 779 |
one puts commands {\tt\string\beginfile$\{$scratch.adr$\}$} and |
| 780 |
{\tt\string\endfile} there respectively, then by adding after |
| 781 |
{\tt\string\endfile} the commands |
| 782 |
|
| 783 |
\setraw |
| 784 |
\inputfile{scratch.adr} |
| 785 |
\beginlabels \inputfile{scratch.adr} \endlabels |
| 786 |
\unsetraw |
| 787 |
|
| 788 |
one gets both form letters and the labels. If one insists on not |
| 789 |
writing out auxiliary scratch files, then use {\tt \string\input |
| 790 |
\ formlett.sty \string\initstyle\ [{\it styles}]$\{${\tt |
| 791 |
article}$\}\{${\it preamble}$\}$} to replace {\tt |
| 792 |
\string\documentstyle\ [formlett, {\it styles}]$\{$article$\}$ |
| 793 |
{\it preamble} \string\begin$\{$document$\}$}, which will be |
| 794 |
valid for \LaTeX\ but ignored for \TeX\ , and will enable one to |
| 795 |
use {\tt \string\labelsquit} at the end to read in the current |
| 796 |
document again with all the letters there converted into the |
| 797 |
corresponding labels. If you only want to execute certain |
| 798 |
commands the first time round (i.e. before {\tt |
| 799 |
\string\labelsquit} re-reads the file again), use {\tt |
| 800 |
\string\firstread$\{${\it commands}$\}$} for this purpose. |
| 801 |
|
| 802 |
} |
| 803 |
|
| 804 |
|
| 805 |
\bigskip |
| 806 |
{\lbold Macros} |
| 807 |
|
| 808 |
|
| 809 |
\smallskip |
| 810 |
|
| 811 |
One of the main technical features of this set of macros is the |
| 812 |
extensive use of arrays, both one dimensional and two |
| 813 |
dimensional. The one dimensional array {\tt STK} that we use is |
| 814 |
essentially an user-defined stack, while the two dimensional |
| 815 |
arrays {\tt LET} and {\tt DEF} are more like structure or record |
| 816 |
in other programming languages. First let us make clear that an |
| 817 |
array (or stack) of name, say {\tt ABC}, will contain elements |
| 818 |
{\tt \string\ABC\it m\tt\t} for one dimensional and {\tt |
| 819 |
\string\ABC\it m\tt*\it n\tt\t} for two dimensional case, where |
| 820 |
$m$ and $n$ are some non-negative integers representing row and |
| 821 |
column numbers respectively. The first element, if necessary, |
| 822 |
will be used to denote the length of that raw. Thus, {\tt |
| 823 |
\string\ABC1*0\t} for instance will denote the number of elements |
| 824 |
in the first raw of a two dimensional array {\tt ABC}. |
| 825 |
|
| 826 |
|
| 827 |
\medskip |
| 828 |
|
| 829 |
Let us now look at how a mechanism of defaulting {\sl macro} |
| 830 |
parameters is formulated. For this purpose, we first define a |
| 831 |
stack {\tt STK} and its stack pointer {\tt \string\STKcount} by |
| 832 |
|
| 833 |
\setraw |
| 834 |
\def\make@STKcount{\csname newcount\endcsname |
| 835 |
\STKcount\global\STKcount=0\relax} |
| 836 |
\ifx\STKcount\undefined@\def\next{% |
| 837 |
\make@STKcount}\else\def\next{}\fi\next |
| 838 |
\long\def\push#1{\global |
| 839 |
\advance\STKcount1\relax |
| 840 |
\expandafter\gdef\csname STK\the |
| 841 |
\STKcount\string~\endcsname{#1}} |
| 842 |
\def\popnil{\expandafter\let |
| 843 |
\expandafter\temp@macro\csname |
| 844 |
STK\the\STKcount\string~\endcsname |
| 845 |
\ifnum\STKcount>0\global\expandafter |
| 846 |
\let\csname STK\the\STKcount |
| 847 |
\string~\endcsname=\undefined@ |
| 848 |
\global\advance\STKcount-1% |
| 849 |
\else |
| 850 |
\def\temp@macro{}\global\STKcount=0% |
| 851 |
\fi\relax } |
| 852 |
\def\pop{\popnil\temp@macro} |
| 853 |
\unsetraw |
| 854 |
|
| 855 |
|
| 856 |
The first four lines of code will ensure that the stack pointer |
| 857 |
will not be flushed if this useful subset of macros is loaded |
| 858 |
again by for instance another style file in the middle of a \TeX |
| 859 |
\ document. With the above code, we can stack away anything by |
| 860 |
{\tt\string\push$\{anything\}$} and later use {\tt \string\pop} |
| 861 |
to recall them or {\tt \string\popnil} to remove one element from |
| 862 |
the stack. |
| 863 |
|
| 864 |
|
| 865 |
\medskip |
| 866 |
So, how can we make defaults for certain empty macro |
| 867 |
parameters? The simplest case is perhaps |
| 868 |
|
| 869 |
|
| 870 |
\setraw |
| 871 |
\long\def\get@nepara[#1][#2]{{% |
| 872 |
\def\next@{#2}% |
| 873 |
\ifx\next@\empty\push{#1}\else |
| 874 |
\push{#2}\fi}\ag@in} |
| 875 |
\long\def\get@para\left@#1\right@{% |
| 876 |
\def\check@{% |
| 877 |
\ifx[\next@ |
| 878 |
\def\full@####1{\get@nepara[#1]####1}% |
| 879 |
\else |
| 880 |
\def\full@{\get@nepara[#1][#1]}\fi |
| 881 |
\full@}% |
| 882 |
\futurelet\next@\check@} |
| 883 |
\unsetraw |
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
Basically, {\tt\string\get@onepara[<A>][<B>]} will push the |
| 888 |
default {\tt <A>} to the stack {\tt STK} unless {\tt <B>} is |
| 889 |
nonempty. And {\tt\string \get@para\string \left@<A>\string |
| 890 |
\right@} will look at the next token to be read, if it is |
| 891 |
character \lq{\tt[}\rq, then reads in a macro parameter in the |
| 892 |
form of {\tt [<B>]} and then push {\tt <B>} to the stack {\tt |
| 893 |
STK}, otherwise push the default {\tt <A>} to that stack. For the |
| 894 |
more general case, we need to define |
| 895 |
|
| 896 |
|
| 897 |
\setraw |
| 898 |
\long\def\do@nepara |
| 899 |
\left@#1\right@#2\p@r@end{% |
| 900 |
\gdef\p@r@data{#2}\global\advance |
| 901 |
\p@r@count1\get@para\left@#1\right@} |
| 902 |
\def\ag@in{\ifx\p@r@data\empty |
| 903 |
\def\next@{\relax\getp@r@s\run@CMD}% |
| 904 |
\else\def\next@{\expandafter\do@nepara |
| 905 |
\p@r@data\p@r@end}% |
| 906 |
\fi\next@} |
| 907 |
\def\run@CMD{\csname STK\the\STKcount |
| 908 |
\string~\endcsname} |
| 909 |
\newcount\p@r@count |
| 910 |
\long\def\st@ckparas#1\p@r@end{% |
| 911 |
\global\p@r@count=0% |
| 912 |
\gdef\p@r@data{#1}\ag@in} |
| 913 |
\unsetraw |
| 914 |
|
| 915 |
|
| 916 |
so that {\tt\string\st@ckparas \string\left@<A>\string\right@ |
| 917 |
...\penalty -20 \string\left@<B>\string\right@ ... |
| 918 |
\string\p@r@end} will look for parameters enclosed in {\tt []} |
| 919 |
one by one, exhausting all the defaults paired by |
| 920 |
{\tt\string\left@} and {\tt \string\right@}. If future tokens |
| 921 |
inside {\tt []} are not found, or empty, the default tokens |
| 922 |
inside the corresponding pair {\tt\string\left@ \string\right@} |
| 923 |
will be used. The new or default tokens will be pushed to the |
| 924 |
general-purpose stack {\tt STK} for a later use, while {\tt |
| 925 |
\string\p@r@count} records the total number of the default macro |
| 926 |
parameters. We note that on exit of {\tt \string\st@ckparas}, the |
| 927 |
control is passed to {\tt\string\runCMD}. |
| 928 |
|
| 929 |
\medskip |
| 930 |
Once all macro parameters are pushed to the stack, we may |
| 931 |
transfer them to separate toks {\tt \string\p@r@one} to {\tt |
| 932 |
\string\p@r@nine} (an easier-to-use format) defined by |
| 933 |
|
| 934 |
\setraw |
| 935 |
\newtoks\p@r@one\newtoks\p@r@two |
| 936 |
\newtoks\p@r@three\newtoks\p@r@four |
| 937 |
\newtoks\p@r@five \newtoks\p@r@six |
| 938 |
\newtoks\p@r@seven\newtoks\p@r@eight |
| 939 |
\newtoks\p@r@nine |
| 940 |
\def\clrp@r@s{\global\p@r@one={}% |
| 941 |
\global\p@r@two={}\global\p@r@three={}% |
| 942 |
\global\p@r@four={}\global\p@r@five={}% |
| 943 |
\global\p@r@six={}\global\p@r@seven={}% |
| 944 |
\global\p@r@eight={}\global\p@r@nine={}} |
| 945 |
\unsetraw |
| 946 |
|
| 947 |
where {\tt\string\clrp@r@s} clears all the parameter toks. We can |
| 948 |
then retrieve parameters from the stack {\tt STK} to the |
| 949 |
parameter toks via {\tt\string \getp@r@s} with the following code |
| 950 |
|
| 951 |
|
| 952 |
\setraw |
| 953 |
\newcount\temp@count |
| 954 |
\def\getp@r@s{\temp@count=\p@r@count |
| 955 |
{\loop |
| 956 |
\ifnum\temp@count>0 |
| 957 |
\expandafter\let\expandafter |
| 958 |
\t@macro\csname STK\the\STKcount |
| 959 |
\string~\endcsname |
| 960 |
\ifcase\temp@count |
| 961 |
\or\global\p@r@one=\expandafter{\t@macro}% |
| 962 |
\or\global\p@r@two=\expandafter{\t@macro}% |
| 963 |
\or\global\p@r@three=\expandafter{\t@macro}% |
| 964 |
\or\global\p@r@four=\expandafter{\t@macro}% |
| 965 |
\or\global\p@r@five=\expandafter{\t@macro}% |
| 966 |
\or\global\p@r@six=\expandafter{\t@macro}% |
| 967 |
\or\global\p@r@seven=\expandafter{\t@macro}% |
| 968 |
\or\global\p@r@eight=\expandafter{\t@macro}% |
| 969 |
\or\global\p@r@nine=\expandafter{\t@macro}% |
| 970 |
\else |
| 971 |
\errmessage |
| 972 |
{Parameter capacity exceeded.}% |
| 973 |
\fi \global\expandafter\let |
| 974 |
\csname STK\the\STKcount |
| 975 |
\string~\endcsname=\undefined@% |
| 976 |
\global\advance\STKcount-1% |
| 977 |
\global\advance\temp@count-1\relax |
| 978 |
\fi |
| 979 |
\ifnum\temp@count>0\repeat}} |
| 980 |
\unsetraw |
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
\medskip |
| 985 |
We are now ready to use the above mechanism to default |
| 986 |
macro parameters for some already defined macros. Suppose we have |
| 987 |
already defined a macro {\tt \string\crudemac[<A>][<B>]} which |
| 988 |
takes two macro parameters {\tt <A>} and {\tt<B>}, and we want to |
| 989 |
define a new macro {\tt \string\smartmac} which behaves like {\tt |
| 990 |
\string\crudemac} but will default the macro parameters {\tt <A>} |
| 991 |
and {\tt <B>} to for instance 9 and 88 respectively. For this |
| 992 |
purpose, we may define {\tt \string\smartmac} via |
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
\setraw |
| 997 |
\def\smartmac{\push{% |
| 998 |
\edef\next@@{\noexpand |
| 999 |
\crudemac[\the\p@r@one][\the\p@r@two]}% |
| 1000 |
\popnil\clrp@r@s\next@@}\st@ckparas |
| 1001 |
\left@9\right@\left@88\right@\p@r@end} |
| 1002 |
\unsetraw |
| 1003 |
|
| 1004 |
This way, all the followings |
| 1005 |
|
| 1006 |
\setraw |
| 1007 |
\crudemac[9][88], \smartmac[9][88], |
| 1008 |
\smartmac, \smartmac[], \smartmac[][], |
| 1009 |
\smartmac[9], \smartmac[9][], \smartmac[][88] |
| 1010 |
\unsetraw |
| 1011 |
|
| 1012 |
are the same under the assumption that we shall not use |
| 1013 |
characters \lq{\tt[}\rqs and \lq{\tt]}\rqs for the macro |
| 1014 |
parameters themselves, and that {\tt\string\crudemac} will not |
| 1015 |
change any {\tt \string\catcode} inside. The reason for this |
| 1016 |
latter condition lies in the fact that when {\tt\string\smartmac} |
| 1017 |
looks at the next character, the character is in a sense already |
| 1018 |
read. If {\tt \string\crudemac} changes the {\tt\string\catcode} |
| 1019 |
of that particular character, then the one that is already read |
| 1020 |
via {\tt\string\futurelet} will have a misleading |
| 1021 |
{\tt\string\catcode}. If one has to change {\tt \string\catcode} |
| 1022 |
inside but wants to avoid this possible misbehavior, always put |
| 1023 |
full number of empty brackets \lq{\tt[]}\rqs for the defaults, or |
| 1024 |
put a {\tt\string\relax} immediately afterwards. Better still, |
| 1025 |
make the last parameter to appear in a mandatory \lq$\{\}$\rqs form |
| 1026 |
rather than the \lq{\tt []}\rqs form via the {\tt \#$\{$} mechanism |
| 1027 |
[1], so that those square brackets can be dropped off. |
| 1028 |
|
| 1029 |
|
| 1030 |
\medskip |
| 1031 |
|
| 1032 |
|
| 1033 |
For example, we as a by-product also defined a 100\% |
| 1034 |
verbatim mode by |
| 1035 |
|
| 1036 |
{\stt |
| 1037 |
\ \ \string\begin@@rawlist[$A$][$B$][$C$][$D$][$E$][$F$]$G$ }\par |
| 1038 |
\setraw |
| 1039 |
<general text> |
| 1040 |
\endrawlist |
| 1041 |
\unsetraw |
| 1042 |
|
| 1043 |
|
| 1044 |
where, for the line numbering of the raw text, {\tt $A$}, ..., |
| 1045 |
{\tt $G$} represent respectively the initial value, increment |
| 1046 |
step, number of digits, font, horizontal position of text, |
| 1047 |
horizontal shift of numbering, and the password to leave raw text |
| 1048 |
mode. Incidentally, {\tt \string\linecount} records the current |
| 1049 |
line numbering count. Our purpose is to define {\tt |
| 1050 |
\string\beginrawlist} so that its format is |
| 1051 |
|
| 1052 |
{\stt |
| 1053 |
\ \ \string\beginrawlist[$A$][$B$][$C$][$D$][$E$][$F$]$\{G\}$}\par |
| 1054 |
|
| 1055 |
in which $A$ to $F$ are {\sl optional} while $\{G\}$ is mandatory |
| 1056 |
even though $G$ can be empty --- implying {\tt |
| 1057 |
\string\endrawlist} is the password to leave the raw-text mode. |
| 1058 |
For this purpose, we first define |
| 1059 |
|
| 1060 |
\setraw |
| 1061 |
\def\begin@rawlist[#1][#2][#3][#4][#5][#6]#{% |
| 1062 |
\begin@@rawlist[#1][#2][#3][#4][#5][#6]}% |
| 1063 |
\unsetraw |
| 1064 |
|
| 1065 |
to make \lq$\{\}$\rqs pair compulsory for {\tt \#7}, then we |
| 1066 |
provide the defaults for {\tt $A$} to {$F$} as |
| 1067 |
{\tt\string\linecount}, {\tt 1}, {\tt 0}, {\tt \string\tiny}, |
| 1068 |
{\tt 0pt} and {\tt 0pt} respectively via |
| 1069 |
|
| 1070 |
\setraw |
| 1071 |
\def\beginrawlist{\push{% |
| 1072 |
\edef\next@@{\noexpand\begin@rawlist |
| 1073 |
[\the\p@r@one][\the\p@r@two][\the\p@r@three]% |
| 1074 |
[\the\p@r@four][\the\p@r@five][\the\p@r@six]}% |
| 1075 |
\popnil\clrp@r@s\next@@}% end of push |
| 1076 |
\font\tiny@rm=cmr5% |
| 1077 |
\edef\temp@macro{% |
| 1078 |
\noexpand\left@\the\linecount\noexpand\right@ |
| 1079 |
\noexpand\left@1\noexpand\right@ |
| 1080 |
\noexpand\left@0\noexpand\right@ |
| 1081 |
\noexpand\left@\noexpand\tiny@rm |
| 1082 |
\noexpand\right@ |
| 1083 |
\noexpand\left@0pt\noexpand\right@ |
| 1084 |
\noexpand\left@0pt\noexpand\right@}% |
| 1085 |
\expandafter\st@ckparas\temp@macro\p@r@end}% |
| 1086 |
\unsetraw |
| 1087 |
|
| 1088 |
\medskip |
| 1089 |
|
| 1090 |
{\smooth |
| 1091 |
\relax Likewise, we could also similarly define {\tt \string\printfile |
| 1092 |
[...]}$\{${\it filename.ext}$\}$ so that \lq{\tt [...]}\rqs takes |
| 1093 |
a same defaulting scheme. } |
| 1094 |
|
| 1095 |
|
| 1096 |
\medskip |
| 1097 |
There are several tiny but very useful macros in {\tt formlett} |
| 1098 |
which are used again and again. One of such macros is for testing |
| 1099 |
if one string contains another string. The following {\tt |
| 1100 |
\string\test@str} tests if string {\tt\#1} is contained in string |
| 1101 |
{\tt\#2} |
| 1102 |
|
| 1103 |
|
| 1104 |
\setraw |
| 1105 |
\newif\iftemp@if \newtoks\temp@toks |
| 1106 |
% return \temp@iftrue if yes, |
| 1107 |
% \first@half,\second@half are global |
| 1108 |
\long\def\test@str#1#2{% |
| 1109 |
\long\def\strip@endmark##1\s@fetymarkI |
| 1110 |
#1\s@fetymark{\gdef\second@half{##1}}% |
| 1111 |
\long\def\strip@markI##1\s@fetymarkI |
| 1112 |
\s@fetymark{\gdef\first@half{##1}}% |
| 1113 |
\long\def\p@rse##1#1##2\s@fetymark{% |
| 1114 |
\gdef\first@half{##1}% |
| 1115 |
\gdef\second@half{##2}% |
| 1116 |
\ifx\second@half\empty |
| 1117 |
\strip@markI##1\s@fetymark\temp@iffalse |
| 1118 |
\else |
| 1119 |
\strip@endmark##2\s@fetymark\temp@iftrue |
| 1120 |
\fi}% |
| 1121 |
\temp@toks={#2\s@fetymarkI#1\s@fetymark}% |
| 1122 |
\expandafter\p@rse\the\temp@toks }% |
| 1123 |
\unsetraw |
| 1124 |
|
| 1125 |
|
| 1126 |
The {\tt\string\first@half} will contain the tokens upto but |
| 1127 |
excluding the substring {\tt\#1}, while the {\tt |
| 1128 |
\string\second@half} will contain the tokens after the {\sl |
| 1129 |
first} appearance of {\tt\#1}. Should {\tt\#2} not contain string |
| 1130 |
{\tt\#1} at all, then {\tt \string\first@half} is the whole |
| 1131 |
string {\tt\#2} whereas {\tt \string\second@half} is empty. |
| 1132 |
|
| 1133 |
\medskip |
| 1134 |
|
| 1135 |
The small macros such as the above one and the stack utilities, |
| 1136 |
though built for the main purpose of {\tt formlett}, provide also |
| 1137 |
a good \lq infrastructure\rqs for other house-keepings. One of |
| 1138 |
the sidekicks of this type is our macro for commenting out blocks |
| 1139 |
of text inside a \TeX\ file. Basically, {\tt |
| 1140 |
\string\begincomment$\{$\it password$\}$} will set {\sl all} |
| 1141 |
characters of code {\tt0} to {\tt \string\MAX@CHR@CODE} |
| 1142 |
(={\tt255} by default) to catcode 11 or 12, and look for the {\it |
| 1143 |
password}, or {\tt \string\endcomment} in the absence of a |
| 1144 |
password, to quit the comment mode. In comparison to a very |
| 1145 |
compact macro {\tt comment.sty} (currently at version 3.0) |
| 1146 |
written by Victor Eijkhout, quitting comment mode via a password |
| 1147 |
here seems more flexible. |
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
\medskip |
| 1153 |
As for the other macros in {\tt formlett}, it is difficult to |
| 1154 |
explain them without printing out all of them. So instead, we |
| 1155 |
shall explain simply one of the strategies in parsing the letter |
| 1156 |
parameters. Suppose $W$ is a list of parameters separated by |
| 1157 |
\lq{\tt+}\rqs and ended by \lq{\tt!}\rq, i.e. $W$ is like |
| 1158 |
{\tt<A>+<B>+...+<S>!}. Then it will be easy to parse all the |
| 1159 |
parameters one by one (to a stack for instance) if we can know |
| 1160 |
whether there is precisely one parameter left over. To detect it, |
| 1161 |
we use |
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
\setraw |
| 1166 |
\newif\ifl@stline |
| 1167 |
\long\def\testl@stline |
| 1168 |
#1+#2!#3\s@fetymark{% |
| 1169 |
\def\next{#2}\ifx\next\empty |
| 1170 |
\l@stlinetrue\else\l@stlinefalse\fi |
| 1171 |
\def\next{#3}\def\nextsample{+!}% |
| 1172 |
\ifx\next\nextsample\l@stlinefalse\fi} |
| 1173 |
\unsetraw |
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
{\smooth Then the command |
| 1178 |
{\tt \string\testl@stline} {\tt $W$+!\string\s@fetymark } |
| 1179 |
will set {\tt \string\l@stlinetrue} if |
| 1180 |
there is only one parameter left in $W$, and will set {\tt |
| 1181 |
\string\l@stlinefalse} if otherwise. } |
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
\medskip |
| 1186 |
|
| 1187 |
Finally, for those wizard users who want to do everything their own way, |
| 1188 |
we just note that if for instance the 3rd letter parameter of the 2nd |
| 1189 |
group of a cluster is given as {\tt<A>}, then {\tt \string\LET2*3\t} |
| 1190 |
will contain {\tt \string\b@group \string\relax {\tt<A>}\string\e@group} |
| 1191 |
right after a cluster is read in. {\tt \string\DEF2*3\string~}, on the |
| 1192 |
other hand, contains the corresponding default parameter in the same |
| 1193 |
fashion. Furthermore, the command |
| 1194 |
{\tt\string\checkparas[$m$][$n$]$\{$LET$\}$} will copy the content of |
| 1195 |
{\tt\string\paras[$m$][$n$]}, minus the `wrapping' extra tokens |
| 1196 |
{\tt\string\b@group\string\relax} and {\tt\string\e@group}, to |
| 1197 |
{\tt\string\cachedata} and set {\tt\string\ifemptyparas} to true or |
| 1198 |
false depending on whether the content is empty or not. This way, a user |
| 1199 |
may even change the characteristics of his letter template by first |
| 1200 |
testing the content of the supplied individual parameters. However, we |
| 1201 |
note that if {\tt\string \loaddefaultparas} is executed, then the {\tt |
| 1202 |
LET} array, when some of its elements are not supplied, will contain the |
| 1203 |
corresponding elements of the {\tt DEF} array. Hence care must be |
| 1204 |
exercised under such circumstances, when interpreting the |
| 1205 |
{\tt\string\cachedata} generated by |
| 1206 |
{\tt\string\checkparas[$m$][$n$]$\{$LET$\}$}. If necessary, we may use |
| 1207 |
{\tt\string\delparadefaults} to delete current default parameter array |
| 1208 |
{\tt DEF} so as to conduct {\tt\string\checkparas$\{$LET$\}$} more |
| 1209 |
precisely. So if anyone wants to manipulate furthermore letter |
| 1210 |
parameters inside a letter template, he or she will now at least know |
| 1211 |
where to look at. |
| 1212 |
|
| 1213 |
%\penalty -50 |
| 1214 |
\bigskip |
| 1215 |
{\lbold References} |
| 1216 |
|
| 1217 |
\smallskip |
| 1218 |
{\parindent=2em |
| 1219 |
\item{[1].} Knuth D E, {\sl The \TeX book}, Reading, Mass., |
| 1220 |
Addison-Wesley, 1992. \par |
| 1221 |
\item{[2].} Piff M, Text merges in \TeX\ and \LaTeX, {\sl TUGboad}, |
| 1222 |
13(4):518, 1993. \par |
| 1223 |
\item{[3].} Damrau J and Wester M, Form letters with 3-across |
| 1224 |
labels capacity, {\sl TUGboat}, 13(4):510, 1991. |
| 1225 |
\par |
| 1226 |
} |
| 1227 |
|
| 1228 |
|
| 1229 |
\penalty -50\bigskip |
| 1230 |
|
| 1231 |
{\lbold Appendix} |
| 1232 |
|
| 1233 |
|
| 1234 |
\smallskip |
| 1235 |
|
| 1236 |
|
| 1237 |
In the followings, we give a brief summary of the new commands |
| 1238 |
given by {\tt formlett} version 2.3. |
| 1239 |
|
| 1240 |
\medskip |
| 1241 |
|
| 1242 |
Let $m$ and $n$ be numbers, $p$, $q$ and $r$ be dimensions, $A$, |
| 1243 |
$B$, $P$, $G$, $C$ and $T$ be tokens, and $X$ be a box. |
| 1244 |
Furthermore, we shall denote by $R$ a full set of letter |
| 1245 |
parameters ended by \lq{\tt !}\rq, with \lq{\tt;}\rqs separating |
| 1246 |
parameters inside a same group and \lq{\tt+}\rqs separating |
| 1247 |
different parameter groups. We moreover denote $R$ by $F$, when |
| 1248 |
\lq{\tt ; + !}\rqs there can be replaced by \lq$P$ $G$ $C$\rqs |
| 1249 |
respectively if {\tt \string\delimiters$\{P\}\{G\}\{C\}$} is |
| 1250 |
issued. In the commands tabulated below, the macro parameters |
| 1251 |
contained in squared brackets support default. In particular, the |
| 1252 |
defaults are $m$={\tt 1}, $n$={\tt 1}, $p$={\tt 8truecm}, |
| 1253 |
$q$={\tt 1.5em}, $r$={\tt 3pt}, $A$={\tt\string\noindent}, |
| 1254 |
$B$={\tt\string\par}, {\tt\string\previewfalse}, |
| 1255 |
{\tt\string\localparastrue} and {\tt\string\nodefaultsfalse}. |
| 1256 |
|
| 1257 |
|
| 1258 |
%\penalty-10000 |
| 1259 |
|
| 1260 |
\vskip 0pt plus 5cm |
| 1261 |
|
| 1262 |
|
| 1263 |
\newdimen\tempdimone |
| 1264 |
\newdimen\tempdimtwo |
| 1265 |
\tempdimone=\hsize |
| 1266 |
\advance\tempdimone by-0.2pt |
| 1267 |
\tempdimtwo=\hsize |
| 1268 |
\advance\tempdimtwo by-1.8in |
| 1269 |
\def\hruler{\hrule width \tempdimone} |
| 1270 |
\long\def\entry#1#2{% |
| 1271 |
\par\hbox to \tempdimone{\noindent |
| 1272 |
\vrule~\textbox[1.7in]{#1}~\hss |
| 1273 |
\vrule~\textbox[\tempdimtwo]{\raggedright#2}~\vrule}% |
| 1274 |
\par} |
| 1275 |
|
| 1276 |
\long\def\longentry#1#2#3{% |
| 1277 |
\par\hbox to \tempdimone{\noindent |
| 1278 |
\vrule~\textbox[3in]{#1}~\hss~\vrule}\par |
| 1279 |
{\kern-8pt \advance\tempdimtwo0.10in |
| 1280 |
\vrule width1.7in height0pt \vrule width\tempdimtwo height 0.4pt \par |
| 1281 |
\kern-3pt} |
| 1282 |
\entry{#2}{#3}} |
| 1283 |
|
| 1284 |
\long\def\Longentry#1#2#3{% |
| 1285 |
\par\hbox to \tempdimone{\noindent |
| 1286 |
\vrule~\textbox[3in]{#1}~\hss~\vrule}\par |
| 1287 |
{\advance\tempdimtwo0.08in\kern-1pt |
| 1288 |
\vrule~\hfill\vrule width \tempdimtwo height 0.4pt \vrule\par |
| 1289 |
\kern-2.5pt}% |
| 1290 |
\entry{#2}{#3}} |
| 1291 |
|
| 1292 |
|
| 1293 |
|
| 1294 |
\medskip \penalty-100 |
| 1295 |
{\eightpoint |
| 1296 |
\nointerlineskip\parskip=0pt |
| 1297 |
|
| 1298 |
\hruler |
| 1299 |
\entry{{\tt\string\paras[$m$][$n$]}}% |
| 1300 |
{$m^{th}$ parameter of $n^{th}$ group }% |
| 1301 |
|
| 1302 |
\entry{{\tt\string\blockparas[$m$][$n$][$A$][$B$]}}% |
| 1303 |
{$m^{th}$ to the last parameter of $n^{th}$ group, each |
| 1304 |
preceded by $A$ and followed by $B$, wrapped by $\{$\penalty |
| 1305 |
1000$\}$ if |
| 1306 |
$B$={\tt\string\relax}} |
| 1307 |
|
| 1308 |
\entry{{\tt\string\addressparas[$m$][$n$][$p$][$q$]}}% |
| 1309 |
{$m^{th}$ to the last parameter of $n^{th}$ group, each put |
| 1310 |
into a box of width $p$ with indent $q$ for wrapped portions} |
| 1311 |
|
| 1312 |
|
| 1313 |
\entry{{\tt\string\loaddefaultparas}}% |
| 1314 |
{fill empty parameters with defaults} |
| 1315 |
|
| 1316 |
\hruler \penalty-1000 |
| 1317 |
\hruler |
| 1318 |
|
| 1319 |
|
| 1320 |
\entry{{\tt\string\checkparas[$m$][$n$]$\{T\}$}}% |
| 1321 |
{$m^{th}$ parameter of $n^{th}$ group copied to {\tt\string\cachedata}; |
| 1322 |
{\tt\string\ifemptyparas} is true if element is empty; $T$ is often |
| 1323 |
{\tt LET} or {\tt DEF}}% |
| 1324 |
|
| 1325 |
\hruler |
| 1326 |
|
| 1327 |
|
| 1328 |
\entry{{\tt\string\moreletter\ $F$}}% |
| 1329 |
{use parameters $F$ to output a new letter} |
| 1330 |
|
| 1331 |
|
| 1332 |
\entry{{\tt\string\paranames\ $R$}}% |
| 1333 |
{use $R$ as parameter names} |
| 1334 |
|
| 1335 |
\entry{{\tt\string\paradefaults\ $R$}}% |
| 1336 |
{use $R$ as default parameters} |
| 1337 |
|
| 1338 |
|
| 1339 |
\entry{{\tt\string\delparadefaults}}% |
| 1340 |
{delete default parameters} |
| 1341 |
|
| 1342 |
%\hruler \penalty-1000 |
| 1343 |
\hruler |
| 1344 |
|
| 1345 |
|
| 1346 |
\entry{{\tt\string\delimiters$\{P\}\{G\}\{C\}$}}% |
| 1347 |
{use $P$, $G$, $C$ as delimiters} |
| 1348 |
|
| 1349 |
|
| 1350 |
\entry{{\tt\string\defaultmarks}}% |
| 1351 |
{use \lq{\tt ; + !}\rqs as delimiters} |
| 1352 |
|
| 1353 |
|
| 1354 |
\entry{{\tt\string\blockmarks}}% |
| 1355 |
{use \lq{\tt ....}\rq, \lq{\tt ----}\rq, \lq{\tt ====}\rqs as delimiters} |
| 1356 |
|
| 1357 |
%\hruler \penalty -1000 |
| 1358 |
\hruler |
| 1359 |
|
| 1360 |
\entry{{\tt\string\preview}}% |
| 1361 |
{highlight parameter positions} |
| 1362 |
|
| 1363 |
\entry{{\tt\string\showparas}}% |
| 1364 |
{display parameter names, if any} |
| 1365 |
|
| 1366 |
\entry{{\tt\string\inputletter$\{file.ext\}$}}% |
| 1367 |
{input letter content} |
| 1368 |
|
| 1369 |
\entry{{\tt\string\inputfile$\{file.ext\}$}}% |
| 1370 |
{input $file.ext$} |
| 1371 |
|
| 1372 |
%\hruler \penalty -1000 |
| 1373 |
\hruler |
| 1374 |
|
| 1375 |
|
| 1376 |
\entry{% |
| 1377 |
$\left\{\matrix{ \hbox{\tt\string\beginletter}\cr |
| 1378 |
\hbox{\tt\string\endletter~~}\cr}\right.$ }% |
| 1379 |
{delimiters for letter content (template)} |
| 1380 |
|
| 1381 |
\entry{% |
| 1382 |
$\left\{\matrix{ \hbox{\tt\string\beginpilemode}\cr |
| 1383 |
\hbox{\tt\string\endpilemode~~}\cr}\right.$ }% |
| 1384 |
{normal letter parameters cluster-wise} |
| 1385 |
|
| 1386 |
|
| 1387 |
\entry{% |
| 1388 |
$\left\{\matrix{ \hbox{\tt\string\beginblockmode}\cr |
| 1389 |
\hbox{\tt\string\endblockmode~~}\cr}\right.$ }% |
| 1390 |
{for line-by-line blocks of parameters, empty lines active |
| 1391 |
within each cluster} |
| 1392 |
|
| 1393 |
|
| 1394 |
\entry{% |
| 1395 |
$\left\{\matrix{ \hbox{\tt\string\beginlinemode}\cr |
| 1396 |
\hbox{\tt\string\endlinemode~~}\cr}\right.$ }% |
| 1397 |
{for line-by-line parameters, empty lines delimit clusters} |
| 1398 |
|
| 1399 |
%\hruler \penalty-1000 |
| 1400 |
\hruler |
| 1401 |
|
| 1402 |
\entry{% |
| 1403 |
$\left\{\matrix{ \hbox{\tt\string\beginrawblockmode$\{T\}$}\cr |
| 1404 |
\hbox{\tt\string\endrawblockmode\ \ \ \ \ }\cr}\right.$ }% |
| 1405 |
{raw text mode; nonempty $T$ replaces {\tt\string\endrawblockmode} |
| 1406 |
to mark end} |
| 1407 |
|
| 1408 |
|
| 1409 |
\entry{% |
| 1410 |
$\left\{\matrix{ \hbox{\tt\string\beginrawlinemode$\{T\}$}\cr |
| 1411 |
\hbox{\tt\string\endrawlinemode\ \ \ \ \ \ }\cr}\right.$ }% |
| 1412 |
{raw text parameters and active spaces etc} |
| 1413 |
|
| 1414 |
\entry{% |
| 1415 |
$\left\{\matrix{ \hbox{\tt\string\begindatamode[$T$]$\{m\}$}\cr |
| 1416 |
\hbox{\tt\string\enddatamode\ \ \ \ \ \ \ \ }\cr}\right.$ }% |
| 1417 |
{$m$ raw text lines for one form letter} |
| 1418 |
|
| 1419 |
\hruler |
| 1420 |
|
| 1421 |
\entry{% |
| 1422 |
$\left\{\matrix{ \hbox{\tt\string\begincolumns[$a$][$b$]}\cr |
| 1423 |
\hbox{\tt\string\endcolumns\ \ \ \ \ \ \ }\cr}\right.$ }% |
| 1424 |
{$a$-columns separated by distance $b$} |
| 1425 |
|
| 1426 |
|
| 1427 |
\entry{% |
| 1428 |
$\left\{\matrix{ \hbox{\tt\string\begincomment$\{T\}$}\cr |
| 1429 |
\hbox{\tt\string\endcomment\ \ \ \ \ }\cr}\right.$\par |
| 1430 |
\ \ \ {\tiny }}% |
| 1431 |
{comment out lines, nonempty $T$ replaces {\tt |
| 1432 |
\string\endcomment} to mark last {\sl full line} for comment} |
| 1433 |
|
| 1434 |
|
| 1435 |
\entry{% |
| 1436 |
$\left\{\matrix{ \hbox{\tt\string\beginfile[$T$]$\{{\it |
| 1437 |
file.ext}\}$}\cr |
| 1438 |
\hbox{\tt\string\endfile\ \ \ \ \ \ \ \ \ \ \ \ \ }\cr}\right.$\par |
| 1439 |
\ \ \ {\tiny }}% |
| 1440 |
{write text verbatim to file {\it file.ext} (empty implies {\tt |
| 1441 |
scr@[email protected]}), nonempty $T$ replaces {\tt |
| 1442 |
\string\endfile} to mark last full line} |
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
\hruler |
| 1447 |
|
| 1448 |
|
| 1449 |
\entry{{\tt\string\PAGENO=1}}% |
| 1450 |
{page number reset to 1} |
| 1451 |
|
| 1452 |
|
| 1453 |
\entry{{\tt\string\NOPAGENUMBERS}}% |
| 1454 |
{no page numbers} |
| 1455 |
|
| 1456 |
|
| 1457 |
\entry{{\tt\string\textbox[$p$]$\{text\}$}}% |
| 1458 |
{$text$ into box of width $p$} |
| 1459 |
|
| 1460 |
|
| 1461 |
\entry{{\tt\string\boxmore[$r$]$\{X\}$}}% |
| 1462 |
{add borderline to box $X$ at a distance $r$} |
| 1463 |
|
| 1464 |
|
| 1465 |
\entry{{\tt\string\addressbox[$p$][$q$]$\{text\}$}}% |
| 1466 |
{$text$ into box of width $p$, with wrapped options indented |
| 1467 |
by $q$} |
| 1468 |
|
| 1469 |
\hruler |
| 1470 |
|
| 1471 |
|
| 1472 |
\entry{{\tt\string\previewfalse}}% |
| 1473 |
{given parameters instead of highlighted boxes will be shown} |
| 1474 |
|
| 1475 |
|
| 1476 |
\entry{{\tt\string\localparastrue}}% |
| 1477 |
{letter parameters put into $\{\}$ before displayed} |
| 1478 |
|
| 1479 |
|
| 1480 |
\entry{{\tt\string\nodefaultsfalse}}% |
| 1481 |
{take defaults for empty letter parameters} |
| 1482 |
|
| 1483 |
\hruler |
| 1484 |
|
| 1485 |
\entry{{\tt\string\previewtrue}}{{\it cf.} above} |
| 1486 |
|
| 1487 |
|
| 1488 |
\entry{{\tt\string\localparasfalse}}{} |
| 1489 |
|
| 1490 |
|
| 1491 |
\entry{{\tt\string\nodefaultstrue}}{} |
| 1492 |
|
| 1493 |
\hruler |
| 1494 |
|
| 1495 |
\vskip0pt plus 1cm |
| 1496 |
~\hfill $\underline{\hbox{\sl Table continues in the next page}}$ |
| 1497 |
|
| 1498 |
\penalty-5000 |
| 1499 |
\hruler |
| 1500 |
|
| 1501 |
|
| 1502 |
\Longentry{% |
| 1503 |
$\left\{\matrix{ \hbox{\tt\string\beginrawlist |
| 1504 |
[$a$][$b$][$c$][$d$][$e$][$f$]$\{g\}$}\cr |
| 1505 |
\hbox{\tt\string\endrawlist\hskip3.4cm}\cr}\right.$ }% |
| 1506 |
{\strut\par{\sl defaults:}\everypar={\hbox{\ \ \ }}\par\par |
| 1507 |
$a$={\tt\string\linecount},\par |
| 1508 |
$b$={\tt1}, $c$={\tt0},\par |
| 1509 |
$d$={\tt\string\tiny@rm}, \par |
| 1510 |
$e$={\tt0pt}, $f$={\tt0pt}, \par |
| 1511 |
$g$={\tt\string\endrawlist}}% |
| 1512 |
{verbatim listing, line count from $a$, step $b$, digits $c$, |
| 1513 |
font $d$, text position $e$, numbering shift $f$, end mark $g$} |
| 1514 |
|
| 1515 |
\hruler \vskip0.5pt |
| 1516 |
\Longentry{% |
| 1517 |
$\matrix{\hbox{\tt \string\printfile |
| 1518 |
[$a$][$b$][$c$][$d$][$e$][$f$]$\{$\it file.ext$\}$}\cr |
| 1519 |
\hbox{}\cr}$}% |
| 1520 |
{\strut\par{\sl defaults:} ~~$c$={\tt6} {\it etc}}% |
| 1521 |
{verbatim listing of {\it file.ext}} |
| 1522 |
|
| 1523 |
\hruler |
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
\Longentry{% |
| 1528 |
$\left\{\matrix{ \hbox{\tt\string\beginlabels |
| 1529 |
[$a$][$b$][$c$][$d$][$e$][$f$]}\cr |
| 1530 |
\hbox{\tt\string\endlabels\hskip3cm}\cr}\right.$ }% |
| 1531 |
{\strut\par{\sl defaults:}\everypar={\hbox{\ \ \ }}\par\par |
| 1532 |
$a$={\tt 20pt}, \par $b$={\tt\string\tt\string\raggedright}, |
| 1533 |
\par $c$={\tt1}, $d$={\tt1}, \par |
| 1534 |
$e$={\tt2.6in}, $f$={\tt2em}}% |
| 1535 |
{form letters become labels: address taken from $c^{th}$ to |
| 1536 |
last parameter of $d^{th}$ group, with width $e$, indent |
| 1537 |
$f$, borderspace $a$ and font toks $b$} |
| 1538 |
|
| 1539 |
\hruler |
| 1540 |
|
| 1541 |
|
| 1542 |
\entry{{\tt\string\firstread$\{T\}$}}% |
| 1543 |
{toks $T$ will not be read if the file is re-read via {\tt |
| 1544 |
\string\labelsquit}} |
| 1545 |
|
| 1546 |
|
| 1547 |
\entry{{\tt\string\initstyle[$a$]$\{b\}\{c\}$}}% |
| 1548 |
{initiation for {\tt\string\labelsquit},with styles $a$, |
| 1549 |
documentstyle $b$ and preamble $c$} |
| 1550 |
|
| 1551 |
\entry{{\tt\string\initclass[$a$][$o$]$\{b\}\{c\}$}}% |
| 1552 |
{similar to {\tt\string\initstyle} ($o$ is \LaTeX2e options), |
| 1553 |
but retains native \LaTeX2e when applicable} |
| 1554 |
|
| 1555 |
|
| 1556 |
\hruler \vskip0.5pt |
| 1557 |
\Longentry{% |
| 1558 |
$\matrix{\hbox{\tt \string\labelsquit |
| 1559 |
[$a$][$b$][$c$][$d$][$e$][$f$]$\{$\it file.ext$\}$}\cr |
| 1560 |
\hbox{}\cr}$}% |
| 1561 |
{\strut\par{\sl defaults:}\everypar={\hbox{\ \ \ }}\par\par |
| 1562 |
see that for {\tt\string\beginlabels}} |
| 1563 |
{quit after converting letters to labels by reading the current |
| 1564 |
document or {\it file.ext}} |
| 1565 |
|
| 1566 |
\hruler |
| 1567 |
|
| 1568 |
|
| 1569 |
|
| 1570 |
\def\ABC{{\tt\esc@}{\it abc}} |
| 1571 |
|
| 1572 |
|
| 1573 |
\entry{{\tt\string\newarray\ABC}}% |
| 1574 |
{make array named {\it abc} along with |
| 1575 |
{\tt\ABC} and {\tt\string\check{\it abc}}} |
| 1576 |
|
| 1577 |
|
| 1578 |
\entry{{\tt\string\delarray\ABC}}% |
| 1579 |
{delete array named {\it abc}} |
| 1580 |
|
| 1581 |
|
| 1582 |
\hruler |
| 1583 |
|
| 1584 |
|
| 1585 |
\entry{{\tt\ABC($m$)=$\{T\}$}}% |
| 1586 |
{assign tokens $T$ to {\tt\ABC($m$)}; |
| 1587 |
{\tt\ABC($m$)} $\equiv$ |
| 1588 |
{\tt\ABC($m_1,...,m_k$)} for |
| 1589 |
$m$=$1+\sum_1^k (m_i-1)*\hbox{\tt\string\dataheight}^{k-i}$} |
| 1590 |
|
| 1591 |
|
| 1592 |
\entry{{\tt\ABC($m$)}}{value of {\tt\ABC($m$)}, |
| 1593 |
if not followed by `{\tt=}'} |
| 1594 |
|
| 1595 |
|
| 1596 |
\entry{{\tt\string\dataheight}}{current array dimension: {\it cf.} |
| 1597 |
{\tt\ABC($m$)}} |
| 1598 |
|
| 1599 |
|
| 1600 |
\entry{{\tt\string\readarray$\{N\}\{a_1 \hbox{\&}\, ..\, \hbox{\&} a_n\}$}}% |
| 1601 |
{equivalent to {\tt\esc@{\it N}(1)}=$a_1$, .., |
| 1602 |
{\tt\esc@{\it N}($n$)}=$a_n$} |
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
\entry{{\tt\string\check{\it abc}($m$)}}% |
| 1607 |
{copy {\tt\ABC($m$)} to {\tt\string\cachedata}; |
| 1608 |
set {\tt\string\ifemptydata} to true/false accordingly} |
| 1609 |
|
| 1610 |
|
| 1611 |
\hruler |
| 1612 |
|
| 1613 |
\entry{{\tt\string\readstyles$\{f_1,...,f_n\}$}}% |
| 1614 |
{read files $f_1$ to $f_n$ with default extension {\tt .sty}; |
| 1615 |
{\tt @}'s catcode set to {\tt 11} during input} |
| 1616 |
|
| 1617 |
\hruler |
| 1618 |
|
| 1619 |
|
| 1620 |
} |
| 1621 |
|
| 1622 |
\footline={\lower5pt |
| 1623 |
\hbox to \hsize |
| 1624 |
{{\rm Jiang Z ~~~{\sl Formlett: ~for letters to multiple receivers} |
| 1625 |
\hss {\sl $\bullet$End of Document$\bullet$} |
| 1626 |
\hss \folio}}} |
| 1627 |
|
| 1628 |
\vskip 8in |
| 1629 |
|
| 1630 |
%\vfill\eject |
| 1631 |
\endcolumns |
| 1632 |
\vfill\eject |
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
%%%%%%%%%%%%%%%%%% |
| 1637 |
% MAKE EXAMPLE1.TEX EXAMPLE2.TEX |
| 1638 |
%%%%%%%%%%%%%%%%%% |
| 1639 |
|
| 1640 |
|
| 1641 |
|
| 1642 |
\message{Can I create <example1.tex> and <example2.tex> ? (y/n) }% |
| 1643 |
\read-1 to \reply \def\nono{n }\def\Nono{N }\def\noNo{no }\def\NoNo{NO }% |
| 1644 |
\def\next{\end{document}}% |
| 1645 |
\ifx\reply\nono\else\ifx\reply\Nono\else\ifx\reply\noNo\else |
| 1646 |
\ifx\reply\NoNo\else\let\next\relax |
| 1647 |
\message{(=== YES ===)}\fi\fi\fi\fi \next |
| 1648 |
|
| 1649 |
|
| 1650 |
|
| 1651 |
|
| 1652 |
\beginfile[EndOfExample1]{example1.tex} |
| 1653 |
|
| 1654 |
% Example1: EXAMPLE for using scratch files |
| 1655 |
% under plain TeX or LaTeX |
| 1656 |
% |
| 1657 |
|
| 1658 |
\input formlett.sty |
| 1659 |
% |
| 1660 |
%%%% MAKE scr@[email protected] |
| 1661 |
% |
| 1662 |
\beginfile{scr@[email protected]} |
| 1663 |
|
| 1664 |
% letter content |
| 1665 |
\boxmore[10pt]{\hbox{\vbox{% BOX FOR BORDERLINE |
| 1666 |
|
| 1667 |
\parindent=0pt |
| 1668 |
\blockparas |
| 1669 |
|
| 1670 |
\bigskip\bigskip |
| 1671 |
|
| 1672 |
Dear \paras, |
| 1673 |
|
| 1674 |
\bigskip |
| 1675 |
|
| 1676 |
This part is typically the letter content. Since we are using a |
| 1677 |
scratch file for our main body of our letter, the letter can be |
| 1678 |
arbitrarily long, in comparison to using {\tt \string\beginletter} |
| 1679 |
and {\tt \string\endletter} mechanism. Using a scratch file enables |
| 1680 |
us to keep everything inside one single file so that it won't be mixed |
| 1681 |
up with other letters. |
| 1682 |
|
| 1683 |
\medskip |
| 1684 |
|
| 1685 |
The idea of scratch file can also be applied to creating the address |
| 1686 |
file, so that the address file can be read for the form letters in the |
| 1687 |
first time and for mailing labels in the second time. These features are |
| 1688 |
the purpose of this particular example. |
| 1689 |
|
| 1690 |
\medskip |
| 1691 |
Thanks for using {\tt formlett.sty}. |
| 1692 |
|
| 1693 |
}}} % END OF BOX FOR BORDERLINE |
| 1694 |
\vfill\eject |
| 1695 |
|
| 1696 |
\endfile |
| 1697 |
|
| 1698 |
|
| 1699 |
% |
| 1700 |
%%%% MAKE scr@[email protected] |
| 1701 |
% |
| 1702 |
\beginfile{scr@[email protected]} |
| 1703 |
% address file |
| 1704 |
\beginlinemode |
| 1705 |
\tt<name> |
| 1706 |
address line one |
| 1707 |
address line two |
| 1708 |
etc |
| 1709 |
|
| 1710 |
\tt<NAME> |
| 1711 |
ADDRESS LINE ONE |
| 1712 |
ADDRESS LINE TWO |
| 1713 |
ETC |
| 1714 |
|
| 1715 |
\endlinemode |
| 1716 |
\endfile |
| 1717 |
|
| 1718 |
|
| 1719 |
% |
| 1720 |
%%% MAIN PROCESSING BODY |
| 1721 |
% |
| 1722 |
|
| 1723 |
\hsize=5in |
| 1724 |
\initstyle{}{} |
| 1725 |
% Above line is put here for being |
| 1726 |
% able to run this file under either TeX or LaTeX. |
| 1727 |
% It may be deleted for TeX. It may also be replaced |
| 1728 |
% under LaTeX by \documentstyle{article} \begin{article} |
| 1729 |
% for instance |
| 1730 |
|
| 1731 |
\inputletter{scr@[email protected]} |
| 1732 |
\inputfile{scr@[email protected]} % for form letters |
| 1733 |
\beginlabels |
| 1734 |
\inputfile{scr@[email protected]} % for labels |
| 1735 |
\endlabels |
| 1736 |
|
| 1737 |
\end{document} |
| 1738 |
|
| 1739 |
EndOfExample1 |
| 1740 |
% above is password |
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
|
| 1747 |
\beginfile{example2.tex}% |
| 1748 |
|
| 1749 |
% Example2: EXAMPLE for self-read |
| 1750 |
% under plain TeX or LaTeX |
| 1751 |
% |
| 1752 |
|
| 1753 |
|
| 1754 |
\input formlett.sty |
| 1755 |
\hsize=3.2in % for plain TeX |
| 1756 |
\initstyle[]{}{\textwidth=3.2in} % for LaTeX |
| 1757 |
|
| 1758 |
% MY LOGO |
| 1759 |
% |
| 1760 |
\catcode`\@=11\relax |
| 1761 |
\def\UWS{{\vbadness=10000 \hbadness=10000 \hfuzz=\maxdimen |
| 1762 |
\vfuzz=\maxdimen \font\tiny=cmr5 \font\small=cmr7 |
| 1763 |
\def\today{\number\day\space\ifcase\month\or January\or February\or |
| 1764 |
March\or April\or May\or June\or July\or August\or September\or |
| 1765 |
October\or November\or December\fi\space\number\year}% |
| 1766 |
\def\make@temp@box{\csname newbox\endcsname \temp@box\relax}% |
| 1767 |
\ifx\temp@box\undefined \def\next{\make@temp@box}\else\def\next{}\fi\next |
| 1768 |
\font\HUGE=cmss10 at 24.87999pt \noindent |
| 1769 |
\setbox\temp@box=\hbox{\vbox to 0pt{\hbox{\HUGE |
| 1770 |
U\hskip6pt W\hskip6pt S}}}% |
| 1771 |
\def\buffdim{65pt}%\wd\temp@box 61.588pt |
| 1772 |
\rlap{\copy\temp@box}% |
| 1773 |
\rlap{\hskip.4pt\copy\temp@box}% |
| 1774 |
\rlap{\hskip.8pt\copy\temp@box}% |
| 1775 |
\rlap{\hskip1.2pt\copy\temp@box}% |
| 1776 |
\rlap{\hskip1.6pt\copy\temp@box}% |
| 1777 |
\rlap{\hskip2pt\copy\temp@box}% |
| 1778 |
\rlap{\hskip2.4pt\copy\temp@box}% |
| 1779 |
\rlap{\hskip2.8pt\copy\temp@box}% |
| 1780 |
\rlap{\hskip6pt\copy\temp@box}% |
| 1781 |
\rlap{\lower23pt \hbox to \buffdim{\tiny \hskip4pt The ~~~University~~~ Of}}% |
| 1782 |
\rlap{\lower25pt \hbox{\hskip2pt |
| 1783 |
\hbox to \buffdim{\vrule width \buffdim depth .2pt}}}% |
| 1784 |
\rlap{\lower32pt \hbox to \buffdim{\small \hskip-1pt WESTERN SYDNEY}}% |
| 1785 |
\setbox\temp@box=\hbox{\vbox{\let\noindent=\hfill |
| 1786 |
\font\small=cmss8 \baselineskip=8pt %plus 0.5pt minus 0.5pt |
| 1787 |
\small \parskip=0pt |
| 1788 |
\noindent School of Computing and IT\par |
| 1789 |
\noindent University of Western Sydney\par |
| 1790 |
\noindent Victoria Road, Parramatta\par |
| 1791 |
\noindent NSW 2150, Australia\par |
| 1792 |
\medskip |
| 1793 |
\noindent Email: [email protected]\par |
| 1794 |
\noindent Tel: ~(INT-) 61- 2- 96859336\par |
| 1795 |
\noindent Fax: ~(INT-) 61- 2- 96859245\par |
| 1796 |
\medskip\bigskip |
| 1797 |
\noindent \tt\today}}% |
| 1798 |
\rlap{\lower3.0cm \hbox{\box\temp@box}}% |
| 1799 |
}\par}\catcode`\@=12\relax |
| 1800 |
% |
| 1801 |
|
| 1802 |
\beginletter |
| 1803 |
\paranames % optional |
| 1804 |
\tt<<FULL NAME>>;% |
| 1805 |
\tt<<ADDRESS-etc>>;% |
| 1806 |
+\tt<<GIVEN NAME>>;% |
| 1807 |
\tt<<MISSING ITEM>>;% |
| 1808 |
\tt<<PHONE NUMBER>>! |
| 1809 |
\loaddefaultparas % optional |
| 1810 |
|
| 1811 |
\NOPAGENUMBERS\parindent=0pt\overfullrule=0pt |
| 1812 |
\UWS \par\bigskip\bigskip\bigskip |
| 1813 |
\noindent{\it\paras[1]}\par |
| 1814 |
\blockparas[2]\par\bigskip |
| 1815 |
|
| 1816 |
Dear \paras[1][2],\par\medskip |
| 1817 |
We have been looking for |
| 1818 |
\paras[2][2] for quite a while |
| 1819 |
without any luck, could you help |
| 1820 |
us out? If so, please ring |
| 1821 |
\paras[3][2]. \par\medskip |
| 1822 |
Cheers!\hfill Zhuhan\vfill\eject |
| 1823 |
\endletter |
| 1824 |
\preview \showparas |
| 1825 |
\eject % \eject here is purely for better labels |
| 1826 |
|
| 1827 |
|
| 1828 |
\paradefaults % optional |
| 1829 |
To whom this may concern |
| 1830 |
+Sir or Madam;something;% |
| 1831 |
061-225-9905! |
| 1832 |
|
| 1833 |
|
| 1834 |
\blockmarks |
| 1835 |
\beginblockmode |
| 1836 |
|
| 1837 |
Mrs L Stenson |
| 1838 |
\#1-20 Sunset Street |
| 1839 |
Hillside, Norway |
| 1840 |
------ separate groups |
| 1841 |
Louise |
| 1842 |
a Bible |
| 1843 |
220-8888 |
| 1844 |
========= separate cluster |
| 1845 |
|
| 1846 |
...... force entry next line |
| 1847 |
|
| 1848 |
Above empty line active |
| 1849 |
|
| 1850 |
\endblockmode comment ignored |
| 1851 |
|
| 1852 |
\defaultmarks |
| 1853 |
\moreletter |
| 1854 |
S Wales,;% |
| 1855 |
\addressbox[2in][1em]{University of Manchester Institute |
| 1856 |
of Science and Technology, This is |
| 1857 |
a long address line: it will be |
| 1858 |
wrapped up automatically.} |
| 1859 |
+;a \TeX\ package \gstr\ manual and |
| 1860 |
many more (\cstr)! |
| 1861 |
|
| 1862 |
\beginlinemode |
| 1863 |
S Pan |
| 1864 |
UNE, Arimdale |
| 1865 |
|
| 1866 |
T Ribbons |
| 1867 |
UMIST, Manchester |
| 1868 |
\endlinemode |
| 1869 |
|
| 1870 |
\beginpilemode |
| 1871 |
|
| 1872 |
C Anderson;42nd Street;USA+Christine;your service invoice! |
| 1873 |
|
| 1874 |
D Holmes;Flat \#2, Finneybank Rd;London+David;the tax receipt;% |
| 1875 |
071-902 7799! |
| 1876 |
|
| 1877 |
\endpilemode |
| 1878 |
|
| 1879 |
\begindatamode{3} % strictly 3 lines for one letter |
| 1880 |
data-#1 |
| 1881 |
data-#2 |
| 1882 |
data-#3 |
| 1883 |
data-#4 |
| 1884 |
data-#5 |
| 1885 |
\enddatamode |
| 1886 |
|
| 1887 |
\ifISLATEX \firstread{\global\textwidth=6in} |
| 1888 |
\else \firstread{\hsize=6in}\fi % make labels double columns |
| 1889 |
|
| 1890 |
\labelsquit{} |
| 1891 |
\end{document} % redundant |
| 1892 |
\endfile |
| 1893 |
|
| 1894 |
|
| 1895 |
|
| 1896 |
\message{Now go and TeX or LaTeX <example1.tex> and <example2.tex>}% |
| 1897 |
|
| 1898 |
|
| 1899 |
\end{document} |
| 1900 |
% |
| 1901 |
% |
| 1902 |
% |
| 1903 |
%ENDDOCUMENT |
| 1904 |
|
| 1905 |
|
| 1906 |
|