summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/yaletter/yaletter.dtx
blob: 0357364972f33e8b9aaba5cdf4f2757da2b60f64 (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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
% \iffalse
% +AMDG  This document was begun on 6 December 1200, the
% feast of St. Nicholas, and it is humbly dedicated to him
% and to the Immaculate Heart of Mary for her prayers, and
% to the Sacred Heart of Jesus for His mercy.
%
% This document is copyright 2016 by Donald P. Goodman, and is
% released publicly under the LaTeX Project Public License.  The
% distribution and modification of this work is constrained by the
% conditions of that license.  See
% 	http://www.latex-project.org/lppl.txt
% for the text of the license.  This document is released
% under version 1.3 of that license, and this work may be distributed
% or modified under the terms of that license or, at your option, any
% later version.
% 
% This work has the LPPL maintenance status 'maintained'.
% 
% The Current Maintainer of this work is Donald P. Goodman
% (dgoodmaniii@gmail.com).
% 
% This work consists of yaletter.dtx, yaletter.ins, and
% derived files yaletter.cls and yaletter.pdf.
% \fi

% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1996/06/01]
%<package>\ProvidesClass{yaletter}[2017/01/01 v1.1 Yet Another Letter Class]
%<*driver>
\documentclass[12pt]{ltxdoc}

\usepackage{doc}
\usepackage{longtable}
\usepackage{array}
\usepackage{lettrine}
	\setcounter{DefaultLines}{3}
	\setlength{\DefaultFindent}{2pt}
	\renewcommand{\LettrineFontHook}{\color{red}}
\usepackage{url}
\usepackage{booktabs}
\usepackage{spverbatim}
\usepackage{graphicx}
\usepackage[]{xellipsis}
\usepackage{listings}
	\lstset{%
		name=macrocode,
		language=[LaTeX]TeX,
		basicstyle=\ttfamily\small,
		columns=,
	}%
\usepackage[paperheight=11in,paperwidth=8.5in,top=1in,bottom=1in,
	right=0.25in,left=1.75in]{geometry}
\usepackage[T1]{fontenc}
\usepackage[typeone]{dozenal}
\usepackage{lmodern}
\usepackage{url}
\usepackage[colorlinks]{hyperref}
\usepackage{makeidx}
\EnableCrossrefs
\PageIndex
\CodelineNumbered
\RecordChanges
\makeindex
\makeatletter
\def\index@prologue{\section*{Index}\markboth{Index}{Index}}
\makeatother
\DoNotIndex{\?,\{,\},\|,\DeclareFontFamily,\DeclareFontShape,
	\DeclareMathAccent,\DeclareMathAlphabet,\DeclareMathDelimiter,
	\DeclareMathSymbol,\DeclareMathVersion,\DeclareSymbolFont,\def,
	\drmsym,\encodingdefault,\familydefault,\fontencoding,\fontfamily,
	\fontseries,\fontshape,\hfil,\hbox,\mathalpha,\mathclose,
	\mathopen,\mathord,\mathversion,\mp,\nabla,\nbshortroman,
	\RedefineMRmdclxvij,\relax,\renewcomand,\RequirePackage,
	\selectfont,\SetMathAlphabet,\SetSymbolFont,\drmsymbolredef,
	\nodefaultfalse,\nodefaultmathfalse,\nodefaultmathtrue,\nodefaulttrue,
	\nodefaulttextfalse,\nodefaulttexttrue,\noindent,\numexpr,
	\acute,\addtolength\advance,\backslash,\baselineskip,
	\char,\counterA,\counterB,\DeclareOption,\ProcessOptions,
	\drmmathlets,\symbolsonlytrue,\if,\else,\fi,\ifnum,\fi,\ifdim,\fi,
	\symbolsonlyfalse,\fontsize,\newif,\newcount,
	\loop,\iter,\let,\renewcommand,\setbox,\setlength,\the,\vss,
	\vskip,\vbox, \newlength, \newcount,\r@@t,\z@,\DeclareMathRadical,
	\DeclareRobustCommand,\bBigg@,\@ifnextchar,\@sqrt,\@makefnmark,
	\@thefnmark,\catcode,\active,\Q,\csname,\endcsname,\define@key,
	\string,\@afterheading,\@afterindentfalse,\AtBeginDocument,
	\begin,\divide,\eject,\end,\everypar,\expandafter,\fancyfoot,
	\fancyhead,\fancyhf,\fancypagestyle,\global,\geometry,
	\hskip,\input,\itshape,\label,\linewidth,\multiply,
	\newcommand,\newdimen,\newgeometry,\nl@@p,\nloop,\normalsize,
	\oddsidemargin,\pagenumbering,\pageref,\pagestyle,\paperheight,
	\paperwidth,\parindent,\parskip,\pdfpageheight,\pdfpagewidth,
	\thepage,\clearpage,\ ,\@setfontsize,\@viiipt,\@viipt,\@vipt,
	\@vpt,\@xiipt,\@xivpt,\@xviipt,\@xxpt,\@xxvpt,\tiny,\huge,
	\Huge,\LARGE,\Large,\large,\scriptsize}

\long\def\example#1#2{%
	\bigskip%
	\hrule%
	\hbox to\linewidth{%
		\hbox to0.5\linewidth{%
			\vbox to2in{\vfil#1\vfil}%
		}\hbox to0.5\linewidth{%
			\vbox to2in{\vfil#2\vfil}%
		}%
	}%
	\hrule%
	\bigskip%
}

\tracingmacros=3 \begin{document} \DocInput{yaletter.dtx}
\end{document}
%</driver> \fi
%
% \title{The |yaletter| Class, v1.1}
% \author{Donald P.\ Goodman III}
% \date{\today}
%
% \maketitle
%
% \begin{abstract}
% \noindent
% The |yaletter| (``Yet Another Letter'') class produces
% letters in a variety of preset, but also any arbitrary,
% formats; handles multiple addresses and letterheads,
% including a ``database'' of each; produces envelopes of
% any size; and produces labels of any size (e.g., label
% sheets).
% \end{abstract}
%
% \section{Introduction}
%
% While it may seem archaic in our days of email and other
% electronic communication, sometimes it remains necessary
% to send a simple letter; and sometimes, even electronic
% messages require a nicely-formatted letter with real
% letterhead.  Yet despite the presence of multiple
% high-quality letter-writing projects, \LaTeX\ seems
% curiously faulty in this regard.  An American letter is a
% very direct thing formatted in a very specific and
% well-defined way, yet despite many attempts I've been
% unable to persuade \LaTeX\ to produce properly spaced and
% styled American-style letters.  It's often a minor
% problem---a rule that I can't get rid of, or excessive
% spacing---but it's a problem that simply ruins the
% appearance of the letter in my judgement.
%
% So here's the |yaletter| class, or the ``yet another''
% letter class.  There are plenty of letter classes, of
% course, but I still think this one fills a gap that just
% wasn't filled before.
%
% This document is typeset in accordance with the \LaTeX\
% \textsc{docstrip} utility, which allows the extraction of
% code and documentation from the same source documentation.
%
% The numbering in this document is in \emph{dozenal}; that
% is, numbering goes 1, 2, 3, 4, 5, 6, 7, 8, 9, \x, \e, 10,
% 11\ldots\  It uses the |dozenal| \LaTeX\ package to make
% this happen.  For more information, visit
% \url{http://www.dozenal.org}.
%
% The package \emph{does not} work with anything but
% |pdftex|; it uses a few |pdftex| primitives internally.  I
% didn't think it was worth the effort to make it generic.
%
% \section{Letter Commands}
% \label{sect:actletcomm}
%
% To begin with, we need to be able to specify actual letter
% commands; that is, commands which create the date, the
% inside address, the salutation, the farewell, the
% signature, and the enclosure line.  Some of these may be
% absent in a particular letter, but a letter document class
% must account for all of them.
%
% These commands will all be defined if you begin your
% document with the following:
%
% \begin{quote}
% |\documentclass{yaletter}|
% \end{quote}
%
% Once you do this, you've got |yaletter| to work with.
%
% |yaletter| does depend on |textpos| (for envelopes and
% labels) and |xkeyval| (for the arguments to
% |\yaoptions|), as well as on |geometry| and |fancyhdr|
% (for the purposes one would expect).  If these are not
% installed, go ahead and install them; otherwise |yaletter|
% can't do its work.
%
% \subsection{Parts of a Letter}
% \label{sub:partsletter}
%
% It is important to understand the parts of a normal
% business letter if you are going to use the |yaletter|
% class, so let's go over those very briefly first.
%
% \begin{figure}[htb]
% \centering
% \includegraphics[scale=0.5]{parts_letter_diagram.png}
% \caption{Parts of a Basic American Letter, Labelled}
% \label{fig:parts}
% \end{figure}
%
% Figure \ref{fig:parts} should be pretty self-explanatory,
% so we won't spend time talking about it.  These are the
% parts of a letter that we'll be discussing, though, and
% this is (mostly) the default appearance of an opening page
% in |yaletter| (\textit{mutatis mutandis}, of course; e.g.,
% you'll almost certainly have a different letterhead).
%
% \subsection{Date Commands}
% \label{sub:dates}
% 
% \DescribeMacro{\yadate}|\yadate| takes a single argument,
% which is the date that you want to be printed.  It is
% indented from the left margin by the length
% \DescribeMacro{\yahdateskip}|\yahdateskip|, which can be
% set in either the plain-\TeX\ length-setting way (e.g.,
% |\yahdateskip=3in|) or the \LaTeX\ way (e.g.,
% |\setlength{\yahdateskip}{3in}|).
%
% The space above and below dates are set by |\ya@predate|
% and |\ya@postdate|, but as the |@| in the names suggest,
% these really shouldn't be set in the document itself.
% These should be consistent across all letters of a given
% type, so preferably they should be set in the |\yaoptions|
% command, as explained in Section \ref{sect:pageopts}.
%
% You can style your date arbitrarily by putting your style
% commands into the macro
% \DescribeMacro{\yadatestyle}|\yadatestyle|.
% |\yadatestyle| is expanded right before the date itself.
% Remember that you need to use font-changing commands, not
% environments, for this; e.g., use |\itshape|, not
% |\textit|.
%
% \subsection{Inside Adress}
% \label{sub:insideaddr}
%
% The ``inside address'' is the address of the addressee; it
% is so called because it appears inside the letter, as
% opposed to on the envelope, where it also appears.  The
% macro \DescribeMacro{\yainsideaddr}|\yainsideaddr| takes a
% single argument, which is the inside address you want to
% be typeset.
%
% The argument of |\yainsideaddr| will be typeset
% left-justified in a box which will be indented by the
% value of
% \DescribeMacro{\yahinsideaddrskip}|\yahinsideaddrskip|.
% Like |\yahdateskip|, this can be adjusted in either plain
% \TeX\ or \LaTeX\ fashion.
%
% You can insert style commands for your inside address
% using the
% \DescribeMacro{\yainsideaddrstyle}|\yainsideaddrstyle|
% macro, which takes one argument, which is the style
% commands you desire.  This is subject to the same
% restrictions as |\yadatestyle|.
%
% The space above and below the inside address is governed
% by |\ya@preinsideaddr| and |\ya@postinsideaddr|; however,
% as the |@| indicates, these should not be adjusted
% internally.  Rather, they should be set using the
% |\yaoptions| command discussed in Section \ref{sect:pageopts}.
%
% A typical inside address would probably look something
% like this:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\yainsideaddr{Great Company Name \\ 1234 Otherplace Road \\ 
	Somewhere, OK  00000}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% It's also possible (and often easier) to use addresses
% defined by the |\defineaddress| command, as explained in
% Section \ref{sect:addresses}.
%
% \subsection{Salutation}
% \label{sub:salutation}
%
% The salutation, typically just ``Dear So-and-so,'' is
% produced by the command
% \DescribeMacro{\yasalutation}|\yasalutation|.  This also
% takes a single argument, the name which you'd like to
% salute.  E.g., running |\yasalutation{Mr.~Anderson}| will
% produce the string, ``Dear Mr.\ Anderson:'' (by default).
%
% It doesn't have to use the word ``Dear,'' or to use a
% colon after the name.  The word used in the salutation is
% inserted by the macro |\ya@saluword|, and the punctuation
% by |\ya@salupunct|.  The spaces above and below the
% salutation are produced by |\ya@presalutation| and
% |\ya@postsalutation|.  All of these, as the |@| sign
% indicates, should not be set in the body of the document;
% rather, they should be set using the |\yaoptions| command
% discussed in Section \ref{sect:pageopts}.
%
% The salutation will be indented from the left by the
% distance |\yahsalutationskip|, which can be set in either
% the plain \TeX\ or \LaTeX\ ways.
%
% The styling of the salutation is governed by
% \DescribeMacro{\yasalutationstyle}|\yasalutationstyle|,
% which is subject to the same limitations as the other
% style commands.
%
% \subsection{Farewell, Signature, and Enclosure}
% \label{sub:faresigs}
%
% We treat these three together, since they always go
% together.  Insert the farewell with
% \DescribeMacro{\yafarewell}|\yafarewell|, which is
% indented from the left margin by the value of
% \DescribeMacro{\yahfarewellskip}|\yahfarewellskip|.  The
% spacing above and below the farewell are governed by
% |\ya@prefarewell| and |\ya@postfarewell|, but these should
% be set using the |\yaoptions| command discussed in Section
% \ref{sect:pageopts}.
%
% By default, this produces the string ``Sincerely,'' but it
% need not use that word or that punctuation.
% |\ya@farewellword| and |\ya@farewellpunct| set each of
% these; however, these should also 
% be set using the |\yaoptions| command discussed in Section
% \ref{sect:pageopts}.
%
% The farewell can be styled with
% \DescribeMacro{\yafarewellstyle}|\yafarewellstyle|, which
% is subject to the same restrictions as the similar
% commands for other parts of the letter.
%
% The signature is given by
% \DescribeMacro{\yasignature}|\yasignature|, which produces
% the value of the macro |\ya@signatureword|, typically set
% in the |\yaoptions| command discussed in Section
% \ref{sect:pageopts}.  Similarly, the space above and below
% the signature is governed by |\ya@presignature| and
% |\ya@postsignature|.  The signature is indented by the
% value of
% \DescribeMacro{\yahsignatureskip}|\yahsignatureskip|,
% which can be set in the usual ways.  It is styled by
% \DescribeMacro{\yasignaturestyle}|\yasignaturestyle|,
% subject to the usual restrictions.
%
% The enclosure is included by issuing
% \DescribeMacro{\yaenclosure}|\yaenclosure|.  This produces
% the value of |\ya@enclosureword|, indented by the value of
% \DescribeMacro{\yahenclosureskip}|\yahenclosureskip|,
% styled according to the value of
% \DescribeMacro{\yaenclosurestyle}|\yaenclosurestyle|.  The
% space above and below it is governed by |\ya@preenclosure|
% and |\ya@postenclosure|.   As usual, commands containing
% |@| should be changed using the |\yaoptions| command
% discussed in Section \ref{sect:pageopts}.
%
% \section{Letter Options}
% \label{sect:pageopts}
%
% Letters simply don't follow the same rules as other typset
% documents.  I've never seen a letter, for example, that
% had two-sided formatting.  (Except, of course, for
% so-called ``open letters,'' but these are really just
% articles or books addressed at a particular person, so
% they're not really our use case here.)  Margins are
% typically much smaller than in other typeset works,
% leading to a much larger typeblock.  Headers and footers
% typically \emph{do} contain rules (lines), often with not
% only the current page number but also the total number of
% pages (e.g., ``Page 2 of 4'').  
%
% So |yaletter| has the command
% \DescribeMacro{\yaoptions}|\yaoptions|, which gives the
% user the ability to set a variety of different dimensions
% within the letter.  It includes |fancyhdr| by itself,
% since the standard \LaTeX\ header styles simply don't
% address the needs of letter-writing.  And |\yaoptions|
% allows one to set many of the dimensions that |fancyhdr|
% requires, so that we can keep these things as far as
% possible in just one place.
%
% |\yaoptions| takes a single argument, which is a list of
% key-value assignments.  In the table below, you'll
% find a table showing the |\yaoptions| keys, along with
% their default values and a brief description of what
% they're for.
%
% By ``key-value'' options, I mean that they are assigned by
% the means of the phrase \emph{key = value}.  For example,
% for a default |yaletter| on half-letter paper, do the
% following:
%
% \begin{quote}
% |\yaoptions{pageheight=8in,pagewidth=5.5in}|
% \end{quote}
%
% All the options here can be set in the same way.
%
% You \emph{can} have multiple |\yaoptions| commands;
% options specified in later ones will override any
% conflicting options in earlier ones.  Therefore, you can
% have options set in a file which you include, then
% override some of them after inputting that file to reset
% some of them.
%
% \begin{center}
% \begin{longtable}{llp{0.5\textwidth}}
% \toprule
% Option & Default & Description \\
% \midrule
% |pageheight| & 11in & The height of the paper \\
% |pagewidth| & 8.5in & The width of the paper \\
% |lftmarg| & 0.5in & The left margin of the letter \\
% |rgtmarg| & 0.5in & The right margin of the letter \\
% |topmarg| & 0.5in & The top margin of the letter \\
% |botmarg| & 1.0in & The bottom margin of the letter \\
% |footskip| & 24pt & The distance bettween the bottom of
%		the typeblock and the bottom of the footer \\
% |headsep| & 12pt& The distance between the bottom of the
%		header and the top of the typeblock \\
% |headheight| & 12pt & The height of the header line \\
% |headwidth| & |\textwidth| & The width of the header and footer
%		lines \\
% |headrulewidth| & 0.4pt & The thickness of the line underneath
%		the header \\
% |footrulewidth| & 0.4pt & The thickness of the line above
%		the footer \\
% |predate| & 24pt & The space between the letterhead (if
%		any) and the date \\
% |postdate| & 12pt & The space after the date \\
% |datehskip| & 0pt & The horizontal space prior to the date \\
% |preinsideaddr| & 12pt & The space inserted before the
%		inside address \\
% |postinsideaddr| & 0pt & The space inserted after the
%		inside address \\
% |insideaddrhskip| & 0pt & The horizontal space inserted
%		prior to the inside address \\
% |presalutation| & 0pt & The space inserted before the
%		salutation \\
% |postsalutation| & 0pt & The space inserted after the
%		salutation \\
% |saluword| & Dear & The word used in the salutation; don't
%		forgot to include a space at the end, if you change this \\
% |salupunct| & : & The punctuation used after the salutation \\
% |saluskip| & 0pt & The horizontal spacing prior to the
%		salutation \\
% |prefarewell| & 0pt & The space inserted before the
%		farewell line (e.g., ``Sincerely,'') \\
% |postfarewell| & 12pt & The space inserted after the
%		farewell line (e.g., ``Sincerely,'') \\
% |farewellskip| & 0pt & The horizontal space inserted prior
%		to the salutation \\
% |farewellword| & Sincerely & The word used in the farewell
%		line \\
% |farewellpunct| & , & The punctuation used after the
%		farewell word \\
% |presignature| & 12pt & The space inserted before the
%		signature line \\
% |postsignature| & 0pt & The space inserted after the
%		signature line \\
% |signatureskip| & 0pt & The horizontal space inserted
%		prior to the signature \\
% |signatureword| & Your Name Here & The content of the
%		signature; typically the name of the letter writer \\
% |preenclosure| & 0pt & The space inserted before the
%		enclosure line \\
% |postenclosure| & 0pt & The space inserted after the
%		enclosure line \\
% |enclosureskip| & 0pt & The horiziontal space inserted
%		prior to the enclosure line \\
% |enclosureword| & Enclosure & The word inserted when there
%		are enclosures \\
% |parskip| & 12pt & The space between paragraphs \\
% |parindent| & 0pt & The indentation of the first line of
%		each paragraph \\
% |datafile| & \emph{None} & The file which |yaletter| will read to
%		get your letter data \\
% \bottomrule
% \end{longtable}
% \end{center}
%
% If you put a suitable |\yaoptions| directive in your data
% file, you need only tell |yaletter| where your data file
% is located by saying 
% |\yaoptions{datafile={yourdatafile}}|, and you'll have
% consistently formatted letters.
%
% Some of these defaults may seem curiously small; remember
% that these values \emph{stack}.  That is, |postdate| and
% |preinsideaddr| are \emph{both} skipped in between the
% date and the inside address.  If there is a parskip, that
% space will be added, too.  So keep these things in mind
% if the spacing seems larger than you expected.  The
% default settings are suitable for a block-formatted
% letter.
%
% The idea behind putting so many different settings in a
% single command is that you can easily run many different
% letters with a consistent look and feel, but by including
% that one command.  However, sometimes you may need to
% change some individual parts of these; e.g., maybe you
% want the name in the signature line to change.  That's
% certainly doable, as we saw in Section
% \ref{sect:actletcomm}.
%
% \section{Letterheads}
% \label{sect:letterheads}
%
% This is an important part of any letter package; you want
% to be able to use nice-looking, fancy letterhead without
% having to (a) buy paper pre-printed with it, or (b)
% hand-code or hand-copy the letterhead into each
% individual document.
%
% So |yaletter| allows you to save your letterheads in a
% data file (probably kept in your |.texlive| directory or
% some similar place).  You can access those letterheads by
% name, by prefixing |\letterhead| to them.
%
% The \DescribeMacro{\defineletterhead}|\defineletterhead|
% macro takes two arguments:  the first is the name of the
% letterhead, the second is the letterhead code itself.
% That code can be of arbitrary complexity (though it's
% probably best to enclose it all in a box to prevent any
% settings you use leaking out into the remainder of the
% document), but we'll use something pretty simple for our
% example here.  Let's say you want the following code for
% your letterhead:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\vbox{%
	\hbox to\linewidth{%
		\fontsize{72pt}{72pt}\selectfont%
		Your Name\hfil%
	}\hbox to\linewidth{%
		\vrule width\textwidth depth1.5pt%
	}
}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% You want to call this letterhead |namehead|.  You can tell
% |yaletter| that this is your letterhead and that it's
% called |namehead| by doing this:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\defineletterhead{namehead}{%
	\vbox{%
		\hbox to\linewidth{%
			\fontsize{72pt}{72pt}\selectfont%
			Your Name\hfil%
		}\hbox to\linewidth{%
			\vrule width\textwidth depth1.5pt%
		}
	}
}%
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% You then actually use this letterhead by calling
% \DescribeMacro{\letterheadNAME}|\letterheadNAME|,
% replacing the string ``NAME'' with the name you assigned
% your letterhead earlier.  In this case, by calling
% |\letterheadnamehead|.
%
% You can also use a letterhead via the
% \DescribeMacro{\yauseletterhead}|\yauseletterhead|
% command, which takes a single argument:  the name assigned
% to the letterhead in the |\defineletterhead| command.  So
% the letterhead we defined as |namehead| can be put into
% the letter with |\yauseletterhead{namehead}|.
%
% So |\yauseletterhead{namehead}| and |\letterheadnamehead|
% are identical in their effect.
%
% This system allows you to maintain as many letterheads as
% you want, and to easily insert them into a letter, by name,
% with the inclusion of merely a single line.
%
% Although we've not done so here, it's a good idea to keep
% your letterhead names in all-caps, or something similarly
% distinctive.
%
% \section{Letter Styles}
% \label{sect:letstyles}
%
% In American usage, there are primarily two styles of
% letter:  ``block'' and ``modified block.''  Block letters
% are universally left-aligned, with a blank space between
% paragraphs and no indentation.  Modified block letters are
% left-aligned, with a blank space between paragraphs and no
% indentation, but with the date, saluation, farewell, and
% signature lines indented to halfway across the page.
%
% |yaletter| adds a ``normal'' style, in which paragraphs
% are typeset as normal; that is, with no space between them
% (other than normal glue) and indentation at the beginning,
% but otherwise identical to modified block style.
%
% Block format is the default for |yaletter|, as it's the
% most common in the United States.  To explicitly request
% block format, issue
% \DescribeMacro{\yaletterblock}|\yaletterblock| in your
% preamble.  To get modified block format, issue
% \DescribeMacro{\yalettermodblock}|\yalettermodblock| in
% your preamble.  To get normal format, issue
% \DescribeMacro{\yaletternormal}|\yaletternormal| in your
% preamble.
%
% The actual space between paragraphs is governed by the
% special length \DescribeMacro{\yaparskip}|\yaparskip|.  To
% change this, use |\setlength{\yaparskip}{2em}| (or
% whatever your desired length is).  This defaults to |12pt|.
%
% The actual indentation for paragraphs is governed by the
% special length \DescribeMacro{\yaparindent}|\yaparindent|.
% To change this, use |\setlength{\yaparindent}{24pt}| (or
% whatever your desired length is).  This defaults to |0pt|.
%
% These parameters mean that you have complete control over
% indentation and paragraph skipping, even after specifying
% a particular format (with |\yaletterblock|, for example).
% Issuing |\yaparskip=24pt| and |\yaparindent=24pt| will
% give you the desired paragraph skip and indentation within
% the normal block format.
%
% The only trick here is to remember that, if you're using
% |\yaletternormal| and you want a non-zero |\parskip|, you
% have to set |\yaparskip| \emph{after} your
% |\begin{document}|.  I'm not really sure why you'd ever
% want to do this, but you know your needs better than I do,
% so I wanted it to be an option.
%
% Further note that these are merely convenience commands;
% you can do everything these letter styles do simply by
% adjusting the parameters in |\yaoptions|.  These little
% macros are merely syntactic sugar.
%
% \section{Headers and Footers}
% \label{sect:headfoot}
%
% It makes sense for letters to have very distinctive
% headers and footers, especially since there is usually no
% indentation beginning paragraphs.  Since paragraph breaks
% are marked only by spacing, when such a break falls at the
% end of a page, it may be hard to tell without a clearly
% marked footer.  But there should not be a header on the
% first page, which has plenty of information already
% included, possibly including a letterhead, to make it very
% clear to the reader what he is looking at.
%
% So |yaletter| includes |fancyhdr|, since it will be needed
% for almost anything.  It furthermore resets both
% |\headrulewidth| and |\footrulewidth| to |0.4pt|, since
% these are both very helpful guides when reading a letter's
% text.  (Note that both of these can be changed, if
% desired, in |\yaoptions|.)
%
% On the first page, the page style is automatically set as
% |yafirstpage|.  |yafirstpage| is defined as follows:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\fancypagestyle{yafirstpage}{%
	\renewcommand\headrulewidth{0pt}
	\renewcommand\footrulewidth{0.4pt}
	\fancyhf{}%
	\fancyfoot[C]{Page \thepage\ of \yalastpage}%
}%
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% If you want the first page footer to be different,
% redefine |yafirstpage| with whatever parameters you would
% like.
%
% Headers on subsequent pages are defined by the page style
% |yaotherpage|:
% 
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\fancypagestyle{yaotherpage}{%
	\renewcommand\headrulewidth{0.4pt}
	\renewcommand\footrulewidth{0.4pt}
	\fancyhf{}%
	\fancyhead[L]{\yawriter\ to \yaaddressee}%
	\fancyhead[R]{\yathedate}%
	\fancyfoot[C]{Page \thepage\ of \yalastpage}%
}%
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% This, too, can of course be redefined to be whatever you
% want it to be, with the usual |fancyhdr| commands.
%
% \section{Special Variables}
% \label{sect:specvar}
%
% In Section \ref{sect:headfoot}, we saw a couple of special
% variables used, which contain values like the addressee of
% the letter, the author of the letter, and so forth.  We
% can use these variables in headers and footers especially,
% but they are useful in other places, as well.
%
% \DescribeMacro{\yawriter}|\yawriter| contains the author
% of the letter.  It is set by using the macro
% \DescribeMacro{\yasetwriter}|\yasetwriter|, and styled
% with the contents of the macro
% \DescribeMacro{\yawriterstyle}|\yawriterstyle|.  For
% example, to set the letter's writer as ``John Doe'' and
% set it in italics, run the following:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\yawriterstyle{\itshape}
\yasetwriter{John Doe}
\yawriter
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% Similarly, there are the macros
% \DescribeMacro{\yasetaddressee}|\yasetaddressee|,
% \DescribeMacro{\yaaddresseestyle}|\yaaddresseestyle|, and
% \DescribeMacro{\yaaddressee}|\yaaddressee|.  These can be
% used with the |\yawriter| commands to develop things like
% the default header, which briefly states the parties to
% the letter.
%
% There is also \DescribeMacro{\yathedate}|\yathedate|,
% which holds the date which was entered in the |\yadate|
% macro, and the \DescribeMacro{\yalastpage}|\yalastpage|,
% which holds the page number of the last page.  (Note that
% this isn't necessarily the last page of your whole
% document, which might be closed by an envelope or label
% page; rather, it's the page which contains the signature.)
%
% \section{Addresses}
% \label{sect:addresses}
%
% It's likely that you have a list of addresses that you
% normally send letters to, and it doesn't make sense for
% you to have to type them every time.  So |yaletter| allows
% you to define addresses, along with shorthands, in a
% database of sorts and refer to them that way, as well as
% simply entering them manually where they need to go.
%
% \DescribeMacro{\defineaddress}|\defineaddress| takes three
% arguments.  The first is the name by which you want to
% refer to the address; the second is the short name, which
% will be inserted into the |\yaaddressee| or |\yawriter|
% spot; and the last is the code of the address itself.  An
% example would be the following:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\defineaddress{FIRST}{Great Company}{%
	Great Company Name \\
	1234 Otherplace Road \\
	Somewhere, OK  00000%
}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% To actual use this address, one has a number of options.
% To use the address as the inside address, |yaletter|
% provides the \DescribeMacro{\yatoaddress}|\yatoaddress|
% macro, which takes the single argument of the name of the
% address defined by |\defineaddress|.  For example:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\yainsideaddr{\yatoaddress{FIRST}}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% The |\yatoaddress| macro both typesets the address itself
% and resets |\yaaddressee| to the short name given in
% |\defineaddress|.
%
% |yaletter| also provides the similar commands
% \DescribeMacro{\yareturnaddress}|\yareturnaddress|, which
% both typesets the address and sets |\yawriter| to the
% short name given in the corresponding |\defineaddress|;
% and \DescribeMacro{\yafromaddress}|\yafromaddress|, which
% sets |\yawriter| but does not typeset the address itself.
%
% Finally, \DescribeMacro{\yaaddress}|\yaaddress| just
% typesets the address, and doesn't set any other variables.
%
% If you already have an address database, it is probably
% helpful to develop a script which will convert your
% addresses into appropriate |\defineaddress| macros.
% Fortunately, this probably isn't very difficult.
%
% \section{Envelopes}
% \label{sect:envelopes}
%
% |yaletter| also provides plenty of facilities for
% typesetting envelopes.  You can use the same convenient
% address facilities for envelopes as you can for letters.
%
% \DescribeMacro{\yaenvelope}|\yaenvelope| is the primary
% macro, and it takes two arguments:  the first is the width
% of the envelope, the second is its height.  These can be
% given in any dimension that |pdftex| understands; likely
% this will be inches or millimeters.  |yaletter| will
% create this envelope at the point in the document that you
% invoke |\yaenvelope|, so if you're doing this in the same
% file as your letter, you should issue this after your
% letter is complete.  It will start a new page if
% necessary.  So, for a standard American business envelope:
%
% \begin{quote}
% |\yaenvelope{9.5in}{4.125in}|
% \end{quote}
% 
% You can control the placing of the return address and the
% to address very precisely.  To select the unit you'd like
% to use for that control, use
% \DescribeMacro{\yaenvunit}|\yaenvunit|, which takes a
% single argument, which is the unit you'd like to use for
% positioning envelope elements.  I have found a tenth of an
% inch convenient for this purpose, and that is consequently
% the default:
%
% \begin{quote}
% |\yaenvunit{0.1in}|
% \end{quote}
%
% You then set the value of several count registers; those
% count registers will be multiplied by the value of
% |\yaenvunit| for positioning.  The registers are:
%
% \begin{center}
% \begin{tabular}{lp{0.6\textwidth}c}
% \toprule
% Dimension & Description & Default\\
% \midrule
% |\yaenvrethskip| & Return address's distance from the left
% edge of the envelope & 2 \\
% |\yaenvretvskip| & Return address's distance from the top
% edge of the envelope & 1 \\
% |\yaenvtohskip| & To address's distance from the left
% edge of the envelope & 42 \\
% |\yaenvtovskip| & To address's distance from the top
% edge of the envelope & 18 \\
% \bottomrule
% \end{tabular}
% \end{center}
%
% Set these in the manner of plain-\TeX\ counts, not \LaTeX\
% counters.  E.g.:
%
% \begin{quote}
% |\yaenvtovskip=5|
% \end{quote}
%
% The actual addresses to be printed are held in
% \DescribeMacro{\yaenvtoaddr}|\yaenvtoaddr|, which holds
% the to address; and
% \DescribeMacro{\yaenvretaddr}|\yaenvretaddr|, which holds
% the return address.  Redefine these before issuing your
% |\yaenvelope| command:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\def\yaenvretaddr{%
	Your Name \\
	7777 Someplace Street \\
	Nowhere, OK  00000%
}%
\def\yaenvtoaddr{\yaaddress{FIRST}}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% Here we have the return address entered manually, but the
% to address entered as an address defined with
% |\defineaddress|, using |\yaaddress|, which typesets the
% address itself but does not set any variables.
%
% Because some envelope sizes are quite common, |yaletter|
% provides them as simple commands.  The table below gives
% these commands along with the envelope size they mimic,
% plus the skips for each of their parts.  The unit of
% skipping is, in all cases, |0.1in|, which you can change
% if you need to adjust this spacing.  Changing the font
% size to any significant degree will likely require such
% adjustments.
%
% All of these commands are prefixed with |ya|; the North
% American sizes are prefixed with |yana|.  Subsequently,
% letters in the names are retained, while digits are made
% lowercase roman numerals.  Finally, |envelope| is suffixed
% to the end.  So, e.g., a C6 envelope becomes
% |\yacvienvelope|.
%
% \begin{longtable}{llcccc}
% \toprule
% {} & {} & Ret. & Ret. & To & To \\
% Size & Command & hskip & vskip & hskip & vskip \\
% \midrule
% No.\ 10 & |\business| & 2 & 1 & 42 & 18 \\
% {} & |\yananoxenvelope| & {} & {} & {} & {} \\
% DL & |\yadlenvelope| & 2 & 1 & 36 & 18 \\
% C6 & |\yacvienvelope| & 2 & 1 & 26 & 20 \\
% C6/C5 & |\yacvicvenvelope| & 2 & 1 & 42 & 18 \\
% C5 & |\yacvenvelope| & 2 & 1 & 38 & 28 \\
% C4 & |\yacivenvelope| & 3 & 3 & 60 & 42 \\
% C3 & |\yaciiienvelope| & 3 & 3 & 84 & 60 \\
% A-2 & |\yanaaiienvelope| & 2 & 1 & 22 & 20 \\
% A-6 & |\yanaavienvelope| & 2 & 1 & 26 & 22 \\
% A-7 & |\yanaaviienvelope| & 2 & 1 & 30 & 24 \\
% A-8 & |\yanaaviiienvelope| & 2 & 1 & 34 & 24 \\
% A-9 & |\yanaaixenvelope| & 2 & 1 & 38 & 28 \\
% A-10 & |\yanaaxenvelope| & 2 & 1 & 42 & 28 \\
% No.\ 6$\frac{3}{4}$ & |\yananovienvelope| & 2 & 1 & 26 & 14 \\
% No.\ 7$\frac{3}{4}$ & |\yananoviienvelope| & 2 & 1 & 32 & 16 \\
% No.\ 9 & |\yananoixenvelope| & 2 & 1 & 36 & 16 \\
% No.\ 11 & |\yananoxienvelope| & 2 & 1 & 48 & 20 \\
% No.\ 12 & |\yananoxiienvelope| & 2 & 1 & 48 & 22 \\
% No.\ 14 & |\yananoxivenvelope| & 2 & 1 & 52 & 24 \\
% \bottomrule
% \end{longtable}
%
% |yaletter| can print any size of envelope; if your printer
% can handle it, |yaletter| can make it.  The table above
% just presents presets for a number of common situations.
%
% It bears repeating that all of these settings assume no
% change in font size; however, especially for the larger
% envelopes, you'll likely want to increase the font size.
% You'll probably want to adjust the hskip and vskip for
% both addresses at that time.
%
% \section{Labels}
% \label{sect:labels}
%
% Oftentimes, however, we don't want to print on envelopes;
% we just want to print on labels, which we can then attach
% to envelopes (or to packages, or to whatever).  |yaletter|
% caters to this need, too.
%
% The main macro is
% \DescribeMacro{\yalabelsheet}|\yalabelsheet|, which due to
% the nature of label sheets takes many arguments which are
% best explained explicitly:
% 
% \begin{center}
% \cmd{\yalabelsheet} \marg{page-width} \marg{page-height}
% \marg{label-width} \marg{label-height}
% \marg{horizontal-separation} \marg{vertical-separation}
% \marg{number-across} \marg{number-down}
% \end{center}
%
% That's \emph{eight} mandatory arguments.  Unfortunately,
% this seems unavoidable; we can't assume that labels are
% evenly spaced on the sheet, nor can we assume that labels
% are sensibly divided on the page.  The macro does assume
% that they are arranged in rows and columns; that is all.
%
% The first six arguments are all lengths, and can be given
% in any unit that \TeX\ understands.  The last two are
% simply integers; so for a sheet of labels grouped in ten
% rows of three, one simply enters |{3}{10}|.
%
% Even these eight parameters are not sufficient, however,
% because we can't assume that the margins of the label
% sheet are the same as the gaps between the labels
% themselves.  So because with \TeX\ we are limited to nine
% arguments, we have separate parameters to set these
% margins:
%
% \begin{center}
% \begin{tabular}{ll}
% \toprule
% \multicolumn{1}{c}{Margin} & \multicolumn{1}{c}{Length} \\
% \midrule
% Left & |\yalableftmarg| \\
% Right & |\yalabrightmarg| \\
% Top & |\yalabtopmarg| \\
% Bottom & |\yalabbotmarg| \\
% \bottomrule
% \end{tabular}
% \end{center}
%
% Redefining \DescribeMacro{\yalabeltext}|\yalabeltext| will
% place the contents of that macro in each of the labels on
% the newly-created label page.  E.g.:
%
% \begin{quote}
% |\def\yalabeltext{\yaaddress{FIRST}}|
% \end{quote}
%
% \noindent
% will result in the address (defined with |\defineaddress|
% with the label |FIRST|) being typeset in all the labels of
% the newly created label sheet.  This is very handy for
% printing out an entire sheet of, say, return address
% labels.  However, because often you'd like different
% text on each label, |\yalabeltext| defaults to empty, so
% no text will be printed onto the labels.  This means that
% it will appear to be a completely blank page.
%
% You can place individual labels with the
% \DescribeMacro{\yaplacelabel}|\yaplacelabel| command:
%
% \begin{center}
% \cmd{\yaplacelabel} \marg{text} \marg{number-across}
% \marg{number-down}
% \end{center}
%
% The first argument contains the text you'd like printed on
% the label; it consists of arbitrary \LaTeX\ code and can
% be the result of other commands (e.g., your first argument
% may be something like |\yaaddress{FIRST}|).  The second
% and third tell |yaletter| which label you'd like this text
% to go on; the second argument is the number of columns
% across you'd like to skip, the third is the number of rows
% down you'd like to skip.
%
% \emph{These are zero-indexed.}  That is, if you want to
% typeset a label in the first label on the sheet, use
% |{0}{0}|.  The whole first row will have a |{0}| for the
% second argument; the whole first column will have a |{0}|
% for the first argument.
%
% Note that |yaletter| does \emph{not} check if you've given
% it coordinates for a label that actually exists; if you
% tell |yaletter| to typeset a label in the fourth row when
% there are only two, it will obey you, and your label will
% be off the page.
%
% Each label is typeset in a box.  You can indent the box
% from the left edge of the label by setting the length
% \DescribeMacro{\yalabelmarg}|\yalabelmarg|, which defaults
% to |0.1in|.
%
% Sometimes it's useful to see the boxes that you're
% typesetting in, even though you don't want to print them.
% E.g., it's easier to tell if your text fits inside the
% label if you can see the boundaries of that label.  To
% make these boxes visible, run
% \DescribeMacro{\yashowboxeson}|\yashowboxeson|; to turn
% them off again, run
% \DescribeMacro{\yashowboxesoff}|\yashowboxesoff|.
%
% When you're defining a new label sheet, it's important not
% to trust the measurements on the packaging.  For example,
% Avery 8660 says that its labels are one inch high, but it
% also says that they're twenty-five millimeters high;
% obviously, one of these must be slightly off, since one
% inch equals 25.4 millimeters.  It turns out that using
% twenty-five millimeters works better, though a ruler
% says that one inch is the correct measurement.  Go figure.
%
% |yaletter| offers two presets for label sheets:  Avery
% 8660 and Avery 8663.  Why these two?  Because those are
% the two that I happen to have in my drawer here!  In any
% case, they are accessed using the
% \DescribeMacro{\yaavery}|\yaavery| command, which takes
% one argument:  the number of the label package.  E.g.,
% |\yaavery{8660}| will give you a sheet of labels in size
% Avery 8660.
%
% Defining new label sheets is relatively easy.  If you want
% it to fit into this |avery| naming scheme, define it like
% so:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\expandafter\def\csname avery????\endcsname{%
	\yalabtopmarg=0.5in
	\yalabbotmarg=0.5in
	\yalableftmarg=0.1875in
	\yalabrightmarg=0.1875in
	\yalabelsheet{8.5in}{11in}{2.625in}{25mm}{0.125in}{0in}{3}{10}%
}%
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% That's the setting for Avery 8660; replace |????| with the
% number label you want, and set the appropriate dimensions.
% Use a ruler; it's the only way to be sure.  Also, the
% margins are typically not printed on the packaging, so
% you'll need to get those manually anyway.  After this,
% |\yaavery{????}| will get you a sheet with these settings.
%
% For some other manufacturer, or if you just don't like
% this naming scheme, don't bother; just replace the first
% line about with |\def\nameoflabelsheet{%|.  Then running
% |\nameoflabelsheet| will give you a label sheet with your
% settings.
%
% \section{Examples}
% \label{sect:letexamples}
%
% A common need for label sheets is to print an entire sheet
% with the same text on each label; typically this is to
% produce a sheet of return-address labels, to be attached
% to envelopes when they are mailed.  A minimal working
% example to produce such a label sheet:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\documentclass{yaletter}
\defineaddress{HOME}{John Q.\ Public}{%
	John Q.\ Public \\
	65 North Buffalo Terrace \\
	Somewhere, NY  00000
}%
\begin{document}
\def\yalabeltext{\yaaddress{HOME}}
\yalabtopmarg=0.5in
\yalabbotmarg=0.5in
\yalableftmarg=0.1875in
\yalabrightmarg=0.1875in
\yashowboxeson
\yalabelsheet{8.5in}{11in}{2.625in}{25mm}{0.125in}{0in}{3}{10}%
\end{document}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% This will yield a sheet of return address labels (note
% that |\yashowboxeson| was issued here, just so we can see
% the labels bettter; for actual printing, one wouldn't want
% this):
%
% \begin{center}
% \fbox{\includegraphics[scale=0.25]{return_sheet-crop.pdf}}
% \end{center}
%
% The basic types of letters are demonstrated in Figure
% \ref{fig:basiclettypes} on page
% \pageref{fig:basiclettypes}.  Specifically, Figure
% \ref{fig:basiclettypes} demonstrates block, modified
% block, and normal-style letters.
%
% \begin{figure}[htbp]
% \begin{tabular}{cc}
%	\fbox{\includegraphics[scale=0.65]{sample_block-crop.pdf}} &
%		\fbox{\includegraphics[scale=0.65]{sample_modblock-crop.pdf}} \\
%	\noalign{\vskip0.25em}
% \itshape Block Style & \itshape Modified Block Style \\
%		\noalign{\vskip1em}
%	\fbox{\includegraphics[scale=0.65]{sample_normal-crop.pdf}} &
%		{} \\
% \itshape Normal Style & {} \\
% \end{tabular}
% \caption{Examples of the Three Basic Letter Types}
% \label{fig:basiclettypes}
% \end{figure}
%
% A standard American business envelope (No.\ 10) is easier
% to form.  A minimal example producing such an envelope is
% as follows:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\documentclass{yaletter}
\defineaddress{HOME}{John Q.\ Public}{%
	Your Name \\
	7777 Someplace Street \\
	Nowhere, OK  00000%
}%
\def\yaenvretaddr{\yaaddress{HOME}}
\def\yaenvtoaddr{Your Name \\ 7777 Someplace Street \\ Nowhere, OK  00000}
\def
\begin{document}
\global\yaenvrethskip=2
\global\yaenvretvskip=1
\global\yaenvtohskip=42
\global\yaenvtovskip=18
\yaenvelope{9.5in}{4.125in}%
\end{document}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% These are the same settings as can be obtained with
% |\yabusiness| or |\yananoxenvelope|; they're spelled out
% here just for demonstrative purposes.  They will result in
% the following envelope:
%
% \begin{center}
% \fbox{\includegraphics[width=\textwidth]{demon_envelope.pdf}}
% \end{center}
%
% You can print this as you wish; but keep in mind that you
% may have to rotate the page with your pdf viewer,
% depending on what orientation your printer expects.
%
% \section{Implementation}
% \label{sect:implementation}
%
% First, we need to require |xkeyval|, so that we can make
% |yaoptions| work correctly without a confusing array of
% options.
%    \begin{macrocode}
\RequirePackage{xkeyval}
%    \end{macrocode}
% Next, define the necessary options and dimensions.  Set
% good defaults for standard \LaTeX\ dimensions.
%    \begin{macrocode}
\pagenumbering{arabic}
\newdimen\ya@lftmarg\ya@lftmarg=0.5in
\newdimen\ya@rgtmarg\ya@rgtmarg=0.5in
\newdimen\ya@topmarg\ya@topmarg=0.5in
\newdimen\ya@botmarg\ya@botmarg=1.0in
\paperheight=\the\pdfpageheight
\paperwidth=\the\pdfpagewidth
\newdimen\ya@pageheight\ya@pageheight=\the\paperheight
\newdimen\ya@pagewidth\ya@pagewidth=\the\paperwidth
\marginparwidth=0pt
\marginparpush=0pt
\topmargin=0pt
\headheight=12pt
\headsep=12pt
\footskip=24pt
\marginparsep=0pt
\newdimen\ya@headheight\ya@headheight=\the\headheight
\newdimen\ya@headsep\ya@headsep=\the\headsep
\newdimen\ya@footskip\ya@footskip=\the\footskip
\oddsidemargin=0pt
\newdimen\ya@oddsidemargin\ya@oddsidemargin=\the\oddsidemargin
\newdimen\ya@headwidth\ya@headwidth=0pt
\def\ya@headrulewidth{0.4pt}
\def\ya@footrulewidth{0.4pt}
\newdimen\ya@predate\ya@predate=12pt
\newdimen\ya@postdate\ya@postdate=12pt
\newdimen\ya@preinsideaddr\ya@preinsideaddr=12pt
\newdimen\ya@postinsideaddr\ya@postinsideaddr=0pt
\newdimen\ya@presalutation\ya@presalutation=0pt
\newdimen\ya@postsalutation\ya@postsalutation=0pt
\newdimen\ya@prefarewell\ya@prefarewell=0pt
\newdimen\ya@postfarewell\ya@postfarewell=12pt
\newdimen\ya@presignature\ya@presignature=12pt
\newdimen\ya@postsignature\ya@postsignature=0pt
\newdimen\ya@preenclosure\ya@preenclosure=0pt
\newdimen\ya@postenclosure\ya@postenclosure=0pt
\def\ya@saluword{Dear }
\def\ya@salupunct{:}
\def\ya@farewellword{Sincerely}
\def\ya@farewellpunct{,}
\def\ya@signatureword{Your Name Here}
\def\ya@enclosureword{Enclosure}
\def\yaaddressee{}
\def\yawriter{}
%    \end{macrocode}
% Now we define |yaoptions| and the actual key-value pairs
% which serve as its argument.
%    \begin{macrocode}
\define@key{yaoptions}{lftmarg}{\global\ya@lftmarg=#1}
\define@key{yaoptions}{rgtmarg}{\global\ya@rgtmarg=#1}
\define@key{yaoptions}{topmarg}{\global\ya@topmarg=#1}
\define@key{yaoptions}{botmarg}{\global\ya@botmarg=#1}
\define@key{yaoptions}{pageheight}{\global\ya@pageheight=#1}
\define@key{yaoptions}{pagewidth}{\global\ya@pagewidth=#1}
\define@key{yaoptions}{footskip}{\global\ya@footskip=#1}
\define@key{yaoptions}{headsep}{\global\ya@headsep=#1}
\define@key{yaoptions}{headheight}{\global\ya@headheight=#1}
\define@key{yaoptions}{oddsidemargin}{\global\ya@oddsidemargin=#1}
\define@key{yaoptions}{headwidth}{\global\ya@headwidth=#1}
\define@key{yaoptions}{headrulewidth}{\global\def\ya@headrulewidth{#1}}
\define@key{yaoptions}{footrulewidth}{\global\def\ya@footrulewidth{#1}}
\define@key{yaoptions}{predate}{\global\ya@predate=#1}
\define@key{yaoptions}{postdate}{\global\ya@postdate=#1}
\define@key{yaoptions}{preinsideaddr}{\global\ya@preinsideaddr=#1}
\define@key{yaoptions}{postinsideaddr}{\global\ya@postinsideaddr=#1}
\define@key{yaoptions}{presalutation}{\global\ya@presalutation=#1}
\define@key{yaoptions}{postsalutation}{\global\ya@postsalutation=#1}
\define@key{yaoptions}{prefarewell}{\global\ya@prefarewell=#1}
\define@key{yaoptions}{postfarewell}{\global\ya@postfarewell=#1}
\define@key{yaoptions}{presignature}{\global\ya@presignature=#1}
\define@key{yaoptions}{postsignature}{\global\ya@postsignature=#1}
\define@key{yaoptions}{preenclosure}{\global\ya@preenclosure=#1}
\define@key{yaoptions}{postenclosure}{\global\ya@postenclosure=#1}
\define@key{yaoptions}{datehskip}{\global\yahdateskip=#1}
\define@key{yaoptions}{insideaddrhskip}{\global\yahinsideaddrskip=#1}
\define@key{yaoptions}{saluskip}{\global\yahsalutationskip=#1}
\define@key{yaoptions}{farewellskip}{\global\yahfarewellskip=#1}
\define@key{yaoptions}{signatureskip}{\global\yahsignatureskip=#1}
\define@key{yaoptions}{enclosureskip}{\global\yahenclosureskip=#1}
\define@key{yaoptions}{enclosureword}{\global\def\ya@enclosureword{#1}}
\define@key{yaoptions}{saluword}{\global\def\ya@saluword{#1}}
\define@key{yaoptions}{salupunct}{\global\def\ya@salupunct{#1}}
\define@key{yaoptions}{farewellword}{\global\def\ya@farewellword{#1}}
\define@key{yaoptions}{farewellpunct}{\global\def\ya@farewellpunct{#1}}
\define@key{yaoptions}{signatureword}{\global\def\ya@signatureword{#1}}
\define@key{yaoptions}{signatureword}{\global\def\ya@signatureword{#1}}
\define@key{yaoptions}{addressee}{\yasetaddressee{#1}}
\define@key{yaoptions}{writer}{\yasetwriter{#1}}
\define@key{yaoptions}{parskip}{\global\yaparskip=#1}
\define@key{yaoptions}{parindent}{\global\yaparindent=#1}
\define@key{yaoptions}{datafile}{\global\input{#1}}
\newcommand\yaoptions[1]{%
	\setkeys{yaoptions}{#1}%
	\geometry{top=\the\ya@topmarg,bottom=\the\ya@botmarg,
		left=\the\ya@lftmarg,right=\the\ya@rgtmarg,
		paperheight=\the\ya@pageheight,paperwidth=\the\ya@pagewidth,
		footskip=\the\ya@footskip,headsep=\the\ya@headsep,
		headheight=\the\ya@headheight}
	\ifdim\ya@headwidth=0pt
		\global\headwidth=\the\textwidth
	\else
		\global\headwidth=\the\ya@headwidth
	\fi
	\renewcommand{\headrulewidth}{\ya@headrulewidth}
	\renewcommand{\footrulewidth}{\ya@footrulewidth}
}%
%    \end{macrocode}
% Set |\normalsize| so that \LaTeX\ doesn't complain.  While
% we're at it, set all the default \LaTeX\ font sizes, since
% people are often accustomed to using them.
%    \begin{macrocode}
\renewcommand{\normalsize}{\fontsize{10pt}{12pt}\selectfont}
\newcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt}
\newcommand\tiny{\@setfontsize\tiny\@vpt\@vipt}
\newcommand\large{\@setfontsize\large\@xiipt{14}}
\newcommand\Large{\@setfontsize\Large\@xivpt{18}}
\newcommand\LARGE{\@setfontsize\LARGE\@xviipt{22}}
\newcommand\huge{\@setfontsize\huge\@xxpt{25}}
\newcommand\Huge{\@setfontsize\Huge\@xxvpt{30}}
%    \end{macrocode}
% Now we need to set some basic page dimensions so that
% |geometry| doesn't complain.  We just start with the
% default page dimensions of the system, getting them from
% pdf\TeX; it doesn't really matter, since |geometry| will
% set the actual dimensions later.
%    \begin{macrocode}
\paperheight=\the\pdfpageheight
\paperwidth=\the\pdfpagewidth
%    \end{macrocode}
% Now we add the necessary package:  |geometry| and
% |fancyhdr|.
%    \begin{macrocode}
\RequirePackage{geometry}
\RequirePackage{fancyhdr}
%    \end{macrocode}
% Now define the default page styles.  The first,
% |yafirstpage|, obviously is used for the first page of the
% letter; the other, |yaotherpage|, is used for all other
% pages.
%    \begin{macrocode}
\fancypagestyle{yafirstpage}{%
	\renewcommand\headrulewidth{0pt}
	\renewcommand\footrulewidth{0.4pt}
	\fancyhf{}%
	\fancyfoot[C]{Page \thepage\ of \yalastpage}%
}%
\fancypagestyle{yaotherpage}{%
	\renewcommand\headrulewidth{0.4pt}
	\renewcommand\footrulewidth{0.4pt}
	\fancyhf{}%
	\fancyhead[L]{\yawriter\ to \yaaddressee}%
	\fancyhead[R]{\yathedate}%
	\fancyfoot[C]{Page \thepage\ of \yalastpage}%
}%
\fancypagestyle{yaenvpage}{%
	\renewcommand\headrulewidth{0pt}
	\renewcommand\footrulewidth{0pt}
	\fancyhf{}%
	\newgeometry{margin=0pt}
}%
%    \end{macrocode}
% Now let's define the letterhead code.  Each letterhead is
% defined by |\defineletterhead|, which takes two arguments:
% the first is the name of the letterhead, which will be
% appended to another command of the form
% |\letterheadNAME|; and the second is the actual letterhead
% code itself.
%    \begin{macrocode}
\def\defineletterhead#1#2{%
	\global\expandafter\def\csname letterhead#1\endcsname{%
		\hbox{#2}%
	}%
	\vskip1pt
	\@afterindentfalse\@afterheading
}%
%    \end{macrocode}
% We also define |\yauseletterhead|, which takes as its
% single argument the name of the letterhead as given in a
% |\defineletterhead| command.
%    \begin{macrocode}
\def\yauseletterhead#1{%
	\csname letterhead#1\endcsname%
}%
%    \end{macrocode}
% Define the basic letter types with |\ya@lettertype|; 0 is
% block, 1 is modified block, and 2 is ``normal.''
%    \begin{macrocode}
\newcount\ya@lettertype\ya@lettertype=0
%    \end{macrocode}
% Now define some of the basic lengths; these are all
% user-accessible (that is, they don't contain ``|@|'').
% They deal with paragraph spacing and indentation.
%    \begin{macrocode}
\newdimen\yaparskip\yaparskip=12pt
\newdimen\yaparindent\yaparindent=0pt
\newdimen\yahdateskip\yahdateskip=0pt
\newdimen\yahinsideaddrskip\yahinsideaddrskip=0pt
\newdimen\yahsalutationskip\yahsalutationskip=0pt
\newdimen\yahfarewellskip\yahfarewellskip=0pt
\newdimen\yahsignatureskip\yahsignatureskip=0pt
\newdimen\yahenclosureskip\yahenclosureskip=0pt
%    \end{macrocode}
% Define the letter types.  These really simply redefine a
% few variables, and can be duplicated entirely with the
% |\yaoptions| command, but these command provide a little
% syntactic sugar.
%    \begin{macrocode}
\def\yaletterblock{%
	\everypar={%
		\parindent=\the\yaparindent
		\parskip=\the\yaparskip
	}%
}%
\def\yalettermodblock{%
	\everypar={%
		\parindent=\the\yaparindent
		\parskip=\the\yaparskip
	}%
	\yahdateskip=\textwidth%
	\divide\yahdateskip by2%
	\yahfarewellskip=\textwidth%
	\divide\yahfarewellskip by 2%
	\yahsignatureskip=\textwidth%
	\divide\yahsignatureskip by 2%
	\ya@lettertype=1
}%
\def\yaletternormal{%
	\yaparskip=0pt
	\yaparindent=24pt
	\everypar={%
		\parindent=\the\yaparindent
		\parskip=\the\yaparskip
	}%
	\yahdateskip=\textwidth%
	\divide\yahdateskip by2%
	\yahfarewellskip=\textwidth%
	\divide\yahfarewellskip by2%
	\yahsignatureskip=\textwidth%
	\divide\yahsignatureskip by2%
	\ya@lettertype=2
	\ya@preinsideaddr=24pt%
	\ya@presalutation=12pt%
	\ya@postsalutation=12pt%
	\ya@prefarewell=12pt%
}
%    \end{macrocode}
% Now we define some of the actual letter macros.  These put
% in things like dates, inside addresses, salutations, and
% so forth.  We use our space parameters, defined above, to
% make sure they all get put in the right places.
%    \begin{macrocode}
\def\yadatestyle{}
\def\yadate#1{%
	\vskip\ya@predate%
	\noindent\hskip\yahdateskip\hbox{%
		\yadatestyle #1%
		\hfil%
	}%
	\vskip\ya@postdate%
	\global\def\yathedate{#1}%
}%
\def\yainsideaddrstyle{}
\def\yainsideaddr#1{%
	\vskip\ya@preinsideaddr%
	\noindent\hskip\yahinsideaddrskip\hbox{%
		\vbox{\yainsideaddrstyle\noindent #1}
	}
	\vskip\ya@postinsideaddr%
}%
\def\yasalutationstyle{}
\def\yasalutation#1{%
	\vskip\ya@presalutation%
	\noindent\hskip\yahsalutationskip\hbox{%
		\yasalutationstyle%
		\ya@saluword #1\ya@salupunct\hfil%
	}%
	\vskip\ya@postsalutation%
}%
\def\yafarewellstyle{}
\def\yafarewell{%
	\vskip\ya@prefarewell%
	\noindent\hskip\yahfarewellskip\hbox{%
		\yafarewellstyle%
		\ya@farewellword\ya@farewellpunct\hfil%
	}%
	\vskip\ya@postfarewell%
}%
\def\yasignaturestyle{}
\def\yasignature{%
	\vskip\ya@presignature%
	\noindent\hskip\yahsignatureskip\hbox{%
		\yasignaturestyle%
		\ya@signatureword\hfil%
	}%
	\vskip\ya@postsignature%
	\label{thelast}%
}%
\def\yaenclosurestyle{}
\def\yaenclosure{%
	\vskip\ya@preenclosure%
	\noindent\hskip\yahenclosureskip\hbox to\linewidth{%
		\yaenclosurestyle%
		\ya@enclosureword\hfil%
	}%
	\vskip\ya@postenclosure%
}%
%    \end{macrocode}
% Now we need to include some code for the headers and
% footers.  These are basically simply container macros with
% certain information contained in them.
%    \begin{macrocode}
\def\yaaddresseestyle{\itshape}
\def\yasetaddressee#1{%
	\global\def\yaaddressee{{\yaaddresseestyle #1}}%
}%
\def\yawriterstyle{\itshape}
\def\yasetwriter#1{%
	\global\def\yawriter{{\yawriterstyle #1}}%
}%
\def\yalastpagestyle{}
\def\yalastpage{%
	{\yalastpagestyle \pageref{thelast}}%
}%
%    \end{macrocode}
% Now we can start work on the address commands.  These
% define addresses that can then be referred to by name,
% similarly to the letterheads.  It takes a first argument,
% the name of the address; a second, the short name you'd
% like to be used for the |\yawriter| or |\yaaddressee|; and
% a third, the actual code for the address.
%    \begin{macrocode}
\def\defineaddress#1#2#3{%
	\global\expandafter\def\csname address#1\endcsname{%
		\noindent\parskip=0pt\parindent=0pt%
		#3%
	}%
	\global\expandafter\def\csname shortname#1\endcsname{%
		#2%
	}%
}%
%    \end{macrocode}
% Now we define three commands to actually use this.  We can
% issue |\yatoaddress{NAME}|, which will typeset the actual
% address and set the addressee to the short name define in
% the second argument of |\defineaddress|; and
% |\yareturnaddress{NAME}|, which does the same thing but
% sets the writer rather than the addressee.
% |\yafromaddress| sets the writer but does not typeset the
% address.  Finally, |\yaaddress| just typesets the address
% by itself.
%    \begin{macrocode}
\def\yatoaddress#1{%
	\yasetaddressee{\csname shortname#1\endcsname}%
	\csname address#1\endcsname%
}%
\def\yareturnaddress#1{%
	\yasetwriter{\csname shortname#1\endcsname}%
	\csname address#1\endcsname%
}%
\def\yafromaddress#1{%
	\yasetwriter{\csname shortname#1\endcsname}%
}%
\def\yaaddress#1{%
	\csname address#1\endcsname%
}%
%    \end{macrocode}
% Now we define the code for envelopes.  This is pretty
% easy to follow.  |\yaenvelope| takes two arguments, the
% width and height of the envelope.  It uses |\yaenvtoaddr|
% and |\yaenvretaddr| in the place the appropriate
% addresses.  We also provide |\yaenvunit| to let people use
% whatever unit they want; |1in| is the default.
%    \begin{macrocode}
\RequirePackage{textpos}
\def\yashowboxeson{%
	\TPoptions{showboxes=true}
}%
\def\yashowboxesoff{%
	\TPoptions{showboxes=false}
}%
\def\yaenvunit#1{%
	\setlength{\TPHorizModule}{#1}%
	\setlength{\TPVertModule}{#1}%
}%
\yaenvunit{0.1in}
\def\yaenvtoaddr{%
	TO ADDRESS%
}%
\def\yaenvretaddr{%
	RETURN ADDRESS%
}%
\newcount\yaenvrethskip\yaenvrethskip=2
\newcount\yaenvretvskip\yaenvretvskip=1
\newcount\yaenvtohskip\yaenvtohskip=42
\newcount\yaenvtovskip\yaenvtovskip=18
\def\yaenvelope#1#2{%
	\clearpage%
	\eject\pdfpagewidth=#1 \pdfpageheight=#2%
	\thispagestyle{yaenvpage}
	\begin{textblock}{100}(\yaenvrethskip,\yaenvretvskip)
		\parskip=0pt\parindent=0pt%
		\yaenvretaddr%
	\end{textblock}
	\begin{textblock}{100}(\yaenvtohskip,\yaenvtovskip)
		\parskip=0pt\parindent=0pt%
		\yaenvtoaddr%
	\end{textblock}
}%
\def\yabusiness{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=42
	\global\yaenvtovskip=18
	\yaenvelope{9.5in}{4.125in}%
}%
\def\yananoxenvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=42
	\global\yaenvtovskip=18
	\yaenvelope{9.5in}{4.125in}%
}%
\def\yadlenvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=36
	\global\yaenvtovskip=18
	\yaenvelope{8.66in}{4.33in}%
}%
\def\yacvienvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=26
	\global\yaenvtovskip=20
	\yaenvelope{6.4in}{4.5in}%
}%
\def\yacvicvenvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=42
	\global\yaenvtovskip=18
	\yaenvelope{9in}{4.5in}%
}%
\def\yacvenvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=38
	\global\yaenvtovskip=28
	\yaenvelope{9in}{6.4in}%
}%
\def\yacivenvelope{%
	\global\yaenvrethskip=3
	\global\yaenvretvskip=3
	\global\yaenvtohskip=60
	\global\yaenvtovskip=42
	\yaenvelope{12.8in}{9.0in}%
}%
\def\yaciiienvelope{%
	\global\yaenvrethskip=3
	\global\yaenvretvskip=3
	\global\yaenvtohskip=84
	\global\yaenvtovskip=60
	\yaenvelope{18in}{12.8in}%
}%
\def\yanaaiienvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=22
	\global\yaenvtovskip=20
	\yaenvelope{5.75in}{4.375in}%
}%
\def\yanaavienvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=26
	\global\yaenvtovskip=22
	\yaenvelope{6.5in}{4.75in}%
}%
\def\yanaaviienvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=30
	\global\yaenvtovskip=24
	\yaenvelope{7.25in}{5.25in}%
}%
\def\yanaaviiienvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=34
	\global\yaenvtovskip=24
	\yaenvelope{8.125in}{5.5in}%
}%
\def\yanaaixenvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=38
	\global\yaenvtovskip=28
	\yaenvelope{8.75in}{5.75in}%
}%
\def\yanaaxenvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=42
	\global\yaenvtovskip=28
	\yaenvelope{9.5in}{6.00in}%
}%
\def\yananovienvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=26
	\global\yaenvtovskip=14
	\yaenvelope{6.5in}{3.625in}%
}%
\def\yananoviienvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=32
	\global\yaenvtovskip=16
	\yaenvelope{7.5in}{3.875in}%
}%
\def\yananoixenvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=36
	\global\yaenvtovskip=16
	\yaenvelope{8.875in}{3.875in}%
}%
\def\yananoxienvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=48
	\global\yaenvtovskip=20
	\yaenvelope{10.375in}{4.5in}%
}%
\def\yananoxiienvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=48
	\global\yaenvtovskip=22
	\yaenvelope{11in}{4.75in}%
}%
\def\yananoxivenvelope{%
	\global\yaenvrethskip=2
	\global\yaenvretvskip=1
	\global\yaenvtohskip=52
	\global\yaenvtovskip=22
	\yaenvelope{11.5in}{5in}%
}%
%    \end{macrocode}
% 
% Lastly, we write the label code.  This code allows us to
% print arbitrary pages of labels.
% 
% First, we must define a little macro to allow nested
% loops.  This is taken wholesale from the accepted
% StackExchange answer to question 58049, written by David
% Carlisle.  As is usual with David Carlisle's code, it's
% remarkable in its simplicity and elegance.
%    \begin{macrocode}
\def\nloop#1{%
	\def\nl@@p##1##2\repeat#1{%
		\def##1{##2\relax\expandafter##1\fi}%
	##1\let##1\relax}%
	\expandafter\nl@@p\csname nl@@p-\string#1\endcsname
}%
%    \end{macrocode}
% Now we can actually define the label code.  First we need
% some lengths and counts.
%    \begin{macrocode}
\newdimen\ya@labwidth
\newdimen\ya@labheight
\newdimen\ya@tempboxh\newdimen\ya@tempboxv
\newcount\ya@loopi
\newcount\ya@loopj
\newcount\ya@numacross
\newcount\ya@numdown
\newdimen\yalabelmarg\yalabelmarg=0.1in
%    \end{macrocode}
% Now comes the main macro, |\yalabelsheet|, which takes
% eight arguments:  the width and height of the page itself,
% the width and height of each label, the vertical and
% horizontal distance between each label, how many labels
% are across the width of the page, and how many labels are
% down the height of the page.
%
% This is a bit convoluted due to length limitations in
% |textpos|; so we have to define the lengths as half their
% real value, then multiply them again by 2 later on.
%    \begin{macrocode}
\def\yalabeltext{}
\newdimen\yalableftmarg\yalableftmarg=0pt
\newdimen\yalabrightmarg\yalabrightmarg=0pt
\newdimen\yalabtopmarg\yalabtopmarg=0pt
\newdimen\yalabbotmarg\yalabbotmarg=0pt
\def\yalabelsheet#1#2#3#4#5#6#7#8{%
	\clearpage%
	\eject\pdfpagewidth=#1 \pdfpageheight=#2%
	\ifdim\yalableftmarg=0pt \yalableftmarg=#5\fi
	\ifdim\yalabrightmarg=0pt \yalabrightmarg=#5\fi
	\ifdim\yalabtopmarg=0pt \yalabtopmarg=#6\fi
	\ifdim\yalabbotmarg=0pt \yalabbotmarg=#6\fi
	\newgeometry{left=\the\yalableftmarg,right=\the\yalabrightmarg,
		top=\the\yalabtopmarg,bottom=\the\yalabbotmarg}
	\thispagestyle{empty}
	\ya@numacross=#7 \ya@numdown=#8
	\ya@labwidth=#3 \ya@labheight=#4
	\ya@tempboxh=#3 \ya@tempboxv=#4
	\advance\ya@labwidth by#5
	\advance\ya@labheight by#6
	\divide\ya@labwidth by2%
	\divide\ya@labheight by2%
	\newcount\ya@acthfact\newcount\ya@actvfact
	\setlength{\TPHorizModule}{\the\ya@labwidth}%
	\setlength{\TPVertModule}{\the\ya@labheight}%
	\ya@loopi=0 \ya@loopj=0
	\nloop1\ifnum\ya@loopi<\ya@numdown
		\ya@actvfact=\ya@loopi\multiply\ya@actvfact by2
		\ya@loopj=0
		\nloop2\ifnum\ya@loopj<\ya@numacross
			\ya@acthfact=\ya@loopj\multiply\ya@acthfact by2
			\begin{textblock}{100}(\ya@acthfact,\ya@actvfact)
				\hbox to#3{%
					\hskip\yalabelmarg%
					\vbox to#4{%
						\parskip=0pt\parindent=0pt%
						\vfil%
							\yalabeltext%
						\vfil%
					}%
				}%
			\end{textblock}
			\advance\ya@loopj by1%
		\repeat2
		\advance\ya@loopi by1%
	\repeat1
}%
%    \end{macrocode}
% Now we define a macro allowing text to be placed in an
% arbitrary label.  Three arguments:  the text to be placed;
% the numbers of columns across; and the number of rows
% down.
%    \begin{macrocode}
\def\yaplacelabel#1#2#3{%
	\newcount\ya@numacrossii\ya@numacrossii=#2
	\newcount\ya@numdownii\ya@numdownii=#3
	\multiply\ya@numacrossii by2%
	\multiply\ya@numdownii by2%
	\begin{textblock}{100}(\ya@numacrossii,\ya@numdownii)
		\hbox to\ya@tempboxh{%
			\hskip\yalabelmarg%
			\vbox to\ya@tempboxv{%
				\parskip=0pt\parindent=0pt%
				\vfil%
					#1%
				\vfil%
			}%
		}%
	\end{textblock}
}%
%    \end{macrocode}
% Define a couple of preset options for certain sheets of
% labels; namely, for the two types of sheets that I
% happened to have near me at the time of writing this
% class.  (Also the only ones I've ever really used.)
% Individual ones are prefixed with |\avery| and then the
% number put afterwards; you call these by issuing
% |\yaavery| with the single argument of the serial number
% of the label sheet you want.
%    \begin{macrocode}
\expandafter\def\csname avery8663\endcsname{%
	\yalabtopmarg=0.5in
	\yalabbotmarg=0.5in
	\yalableftmarg=0.15625in
	\yalabrightmarg=0.15625in
	\yalabelsheet{8.5in}{11in}{4in}{1.95in}{0.15625in}{0in}{2}{5}%
}%
\expandafter\def\csname avery8660\endcsname{%
	\yalabtopmarg=0.5in
	\yalabbotmarg=0.5in
	\yalableftmarg=0.1875in
	\yalabrightmarg=0.1875in
	\yalabelsheet{8.5in}{11in}{2.625in}{25mm}{0.125in}{0in}{3}{10}%
}%
\def\yaavery#1{%
	\csname avery#1\endcsname%
}%
%    \end{macrocode}
% Finally, we put in some code to run at the
% |\begin{document}| command, just to get the ball rolling.
%    \begin{macrocode}
\AtBeginDocument{%
	\pagestyle{yaotherpage}%
	\thispagestyle{yafirstpage}%
	\ifnum\ya@lettertype=0
		\yaletterblock
	\fi\ifnum\ya@lettertype=1
		\yalettermodblock
	\fi\ifnum\ya@lettertype=2
		\yaletternormal
	\fi
}
%    \end{macrocode}
%
% Happy \TeX{}ing!
%
% \PrintIndex