% \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 %\NeedsTeXFormat{LaTeX2e}[1996/06/01] %\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} % \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 % % \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 % % \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 % % \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 % % \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 % % \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 % % \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 % % \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 % % \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 % % \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 % % \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 % % \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 % % \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