Sharedwww / job / ucbletter.clsOpen in CoCalc
% ucbletter.cls
% Written by Paul Vojta, 15 Sep 1995.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% To change the date use the following command:
% \def\today{November 12, 1999}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Announce the class name and version.

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ucbletter}[1997/11/23 University of California letter class]

% wide option - make the text wider (and taller).

\let\@wide 0
\DeclareOption{wide}{\let\@wide 1}

% signed option - memo only - put a letter-style closing at the end

\let\@signed 0
\DeclareOption{signed}{\let\@signed 1}

% center option - center the text in the page automatically

\let\@autocenter\@empty
\DeclareOption{center}{\renewcommand\@autocenter{\oddsidemargin.5\paperwidth
  \advance\oddsidemargin-1in\relax  \advance\oddsidemargin-.5\textwidth
  \evensidemargin\oddsidemargin  \indentedwidth.5\textwidth
  \@tempdima\@oldtextheight  \advance\@tempdima-\textheight
  \advance\topmargin.25\@tempdima  \advance\headsep.25\@tempdima
  \advance\footskip.5\@tempdima
  \let\@fixbottom\@dofixbottom}}

% Pass other options on to the base letter class.

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{letter}}

\ProcessOptions
\LoadClass{letter}

%    ****************************************
%    *           LETTER COMMANDS            *
%    ****************************************
%
% The following declarations, shown with examples, give information
% about the sender:
%
% \name{Dr. L. User} : to be used for the return address on the
%          envelope.
% \signature{Larry User} : goes after the closing.
% \address{3245 Foo St.\\Gnu York} : used as the return address in the
%          letter and on the envelope.  If not declared, then an
%          institutional standard address is used.  If declared, then
%          the letterhead is suppressed unless \letterheadanyway is used.
% \letterheadanyway : Causes the letterhead to appear even if the \address
%          macro is used.
% \location{Room 374} : Acts as modifier to the standard institutional
%          address.
% \telephone{(415)123-4567} : Just in case some style puts it on the
%          letter.
% \email{[email protected]} : Put into the letterhead.
% \sigspace=36pt: amount of space to allow for the signature.  The default
%          value is 36 points, which is equivalent to four typewriter line
%          spaces.  This is the standard for business letters.  I've seen more
%          space used, but not less, and recommend against decreasing it,
%          although most requests to change it seem to refer to decreasing it.
%          I should put in a nasty warning if people put in too little space.
%
% In all of the above, the \sfcode for '.' is set to 1000, so one never needs
% to say "Mr.\ User".
%
% The following modify the letterhead; default values are declared at the end
% of the file:
%
% \department{DEPARTMENT OF REDUNDANCY DEPARTMENT}
% \upperaddress{1234 CHANNING WAY}
% \mailcode{9876}
%
% N.B.:  \department erases whatever \mailcode is in effect, so the \mailcode
% must come _after_ the \department.
%
% In this installation, the letterhead appears as:
%
% --------------------------------- <logo, etc.> ----------------
% \department                           \upperaddress
% \location                             BERKELEY, CALIFORNIA  94720-\mailcode
% \email *                              \telephone
%                                       \email *
%                                       \address
%                                       date
%
% * By default, the \email appears on the right; this can be overridden by
%   specifying \emailatleft or \emailatright.
%
% The macro \adjustmargins can be used to make the margins wider--for example,
% \adjustmargins{.5in}.  This affects top and bottom margins as well, but not
% the placement of the letterhead.  This should be done before the macro
% \begin{document}.
%
% Another option is to set \textwidth and \textheight directly.  Again, this
% should be done before \begin{document}; you should also adjust \oddsidemargin,
% \evensidemargin, and \indentedwidth if you change \textwidth, and \topmargin,
% \headsep, and \footskip if you change \textheight.  An alternative is to
% use the center option on the \documentclass line; it will then center the
% letter automatically.
%
% The signature will appear on the right, aligned with the address, if one is
% given; otherwise it will appear on the left.  This can be overridden with
% \closingatright or \closingatleft.
%
% The \makelabels declaration causes mailing labels to be made.  It
% must go before the \begin{document} command.
%
% The letter environment: creates a new letter, starting from page 1.
% (The first page is unnumbered.)  It has a single argument, which
% is the addressee and his/her address, as in
%        \begin{letter}{Sam Jones \\
%                       Institute for Retarded Study\\ Princeton, N.J.}
%
% Local declarations, such as \address, can follow the \begin{letter}.
%
% For informal letters, the address of the recipient can be left out:
%        \begin{letter}{}
%
% Text is begun with the \opening command, whose argument generates the
% salutation, as in
%           \opening{Dear Henry,}
% The body of the letter follows, ended by a \closing command, as in
%            \closing{Yours truly,}
% The 'signature' is provided automatically.
%
%  After the \closing you can put arbitrary stuff, which is typeset
%  with \parindent = 0 and no page breaking.  Commands designed
%  for use after the closing are:
%
%  \cc{Tinker\\Evers\\Chance} -- which produces:
%        cc: Tinker
%            Evers
%            Chance
%
%  \encl{Foo(2)\\Bar} -- which produces:
%        encl: Foo(2)
%              Bar
%
%  THE MEMO ENVIRONMENT
%
% This format also implements the UC interdepartmental memo format as a "memo"
% environment.  The use is much the same as for the letter environment;
% we will give here the differences.
%
% The \begin macro has one argument giving the recipient(s); for example,
%       \begin{memo}{Sam Jones\\Nicolas Bourbaki}
% To declare the subject of the memo, the \begin may be followed IMMEDIATELY
% by a \subject or \re macro:
%       \re{Our recent discussion}
% The text of the memo follows; the \opening macro, if present, is ignored.
% After the memo, one can invoke the \closing macro (whose argument, in this
% case, is ignored; the macro merely serves the purpose of preventing further
% page breaks).  The usual \cc and \encl options may follow this; if they are
% not used, then there is no point in using the \closing macro, either.
% The reason for keeping the \opening and \closing macros is so that a letter
% can be converted to a memo merely by changing the name of the environment.
% The converse works as well:  the \subject or \re macros are ignored in the
% letter environment.
%
% However, there is an option, which allows the end of the memo to be treated
% as a signed letter.  To specify this option, just include "signed" as one
% of the options in the \documentstyle line.  In that case the \closing
% macro functions just as it does for a letter.
%
% The format of the top of the memo is:
%
%                                       BERKELEY:  \department
%                                                  \location
%                                                  \upperaddress
%                                                  \telephone
%                                                  \email
%
%                                                  date
%
%
%  DOCUMENT STYLE PARAMETERS AND COMMANDS.  CHANGE THESE TO
%  CUSTOMIZE LETTER STYLE.
%
%  \opening{Dear Mr. Foo:}-
%     Should produce everything up to and including the 'Dear Mr. Foo:'
%     and a \par command that follows.  Since there's a \vfil at the
%     bottom of every page, it can add vertical  fil  to position a
%     short letter. It should use the following commands:
%
%     \toname       : name part of 'to' address.
%                     Will be one line long.
%     \toaddress    : address part of 'to' address.
%                     Lines separated by \\.
%     \fromname     : name of sender.
%     \fromaddress  : argument of current \address declaration--
%                     null if none.  Should use standard institutional
%                     address if null.
%     \fromlocation : argument of current \location declaration--
%                     null if none.
%     \telephonenum : argument of current \telephone declaration--
%                     null if none.
%     \emailaddr    : argument of current \email declaration
%     \departmentname:argument of current \department declaration
%     \[email protected]: argument of current \aboveaddress declaration
%     \frommailcode : argument of current \mailcode declaration
%
%     Note that  \ifx\foo\@empty  tests for a null value of \foo.
%
%  \closing{TXT} : Generates the closing matter, and the signature.
%     An obvious thing to do is to use a \parbox for the closing
%     and the signature.  Should use the following:
%
%     \fromsig    : argument of current \signature declaration or,
%                   if null, the \fromname .
%     \stopbreaks : a macro that inhibits page breaking.
%
%  \cc{ARG} and \encl{ARG} : obvious use of a \parbox[t] .
%
%  \ps : The only thing that this needs to do is call \startbreaks,
%        which allows page breaking again.
%
%  \stopletter : Command called by \endletter to do the following:
%     * Add any desired  fil  or other material at the end of the
%       letter.
%     * Define \returnaddress to be the return address for the mailing
%       label.  More precisely, it is the first argument of the \mlabel
%       command described below. It should be \def'd to null if the
%       return address doesn't appear on the labels.  Any command,
%       other than \\, that should not be expanded until the \mlabel
%       command is actually executed must be preceded by \protect.
%       Whenever possible, \protect commands in the definition of
%       \returnaddress---it's much more efficient that way.  In
%       particular, when the standard return address is used, you
%       should \def \returnaddress to something like
%       \protect\standardreturnaddress .
%
% CUSTOMIZING THE LABELS
%
% Commands for generating the labels are put on the .AUX file, which is
% read in and processed by the \end{document} command.  You have to
% define the following two commands:
%
%    \startlabels : Should reset the page layout parameters if
%        necessary.
%
%    \mlabel{RETURN ADDRESS}{TO ADDRESS} : Command to generate a single
%        label.
%


% SPACEFACTORS:
%   In return addresses, etc., periods are treated as any other character, due
%   to the preponderance of abbreviations.

\def\@dotfix{\sfcode`\.\@m}


% FONTS

\font\uc=ucseal60
%\font\uc=cmr5 at 5\[email protected]
\font\five=cmr5 at 5\[email protected]
\font\six=cmr6 at 6\[email protected]
\font\topfont=cmr12 at 12\[email protected]
\font\emailfont=cmtt8 at 8\[email protected]

% DIMENSIONS

\newdimen\@lhdright        \@lhdright -4.5in
\newdimen\@lhddown         \@lhddown -26\[email protected]
\newdimen\@mhdright        \@mhdright 183\[email protected]
\newdimen\@mhddown         \@mhddown -44\[email protected]
\newdimen\emailskip        \emailskip9pt% baselineskip for email address
                           \setlength\footskip{79\[email protected]}
\newdimen\sigspace         \sigspace 36\[email protected]
\newdimen\@oldtextheight   \@oldtextheight\textheight

\let\@fixbottom\relax

\def\@dofixbottom{\let\@tempa\@evenfoot
  \ifx\@empty\@oddfoot\else\let\@tempa\@oddfoot\fi
  \ifx\@empty\@tempa\else\ifdim\footskip<20\[email protected]
    \advance\textheight\footskip \footskip 20\[email protected] \advance\textheight-\footskip
  \fi\fi}

\def\adjustmargins#1{\@tempdima#1 \advance\textwidth-2\@tempdima
  \advance\longindentation-\@tempdima
  \advance\oddsidemargin\@tempdima  \advance\evensidemargin\@tempdima
  \advance\textheight-2\@tempdima
  \advance\topmargin.5\@tempdima  \advance\headsep.5\@tempdima
  \advance\footskip\@tempdima
  \let\@fixbottom\@dofixbottom}

\ifx\@wide 1 \adjustmargins{-53\[email protected]}\fi


%    ****************************************
%    *        THE UCB LETTER FORMAT         *
%    ****************************************

%|% Redefine the page style for the first page, so as to include the letterhead.

%|\renewcommand{\[email protected]}{%
%|   \renewcommand{\@oddhead}{<letterhead goes here>}%
%|   \renewcommand{\@oddfoot}{<letterfoot goes here>}%
%|}

\newsavebox{\letterhead}
\setbox\letterhead\vbox{
  \hbox{\topfont UNIVERSITY OF CALIFORNIA, BERKELEY}
  \vskip 8\[email protected]
  \hbox{\def\dot{\lower1\[email protected]\hbox{$\cdot$}}\mathsurround2.9\[email protected]\five
    \vbox{\hrule height0.2\[email protected]
      \hbox to322\[email protected]{\vrule height9.2\[email protected] depth5.5\[email protected] width\[email protected]\
        BERKELEY\dot DAVIS\dot IRVINE\dot LOS ANGELES\dot
        RIVERSIDE\dot SAN DIEGO\dot SAN FRANCISCO\hss}
      \hrule height0.2\[email protected]}%
    \setbox0\hbox{\lower18\[email protected]\hbox{\uc C}}\ht0=26\[email protected]\dp0=30\[email protected]
    \kern-4\[email protected]\box0\kern-4\[email protected]
    \vbox{\hrule height0.2\[email protected]
      \hbox to122\[email protected]{\vrule height9.2\[email protected] depth5.5\[email protected] width\[email protected]\hss
        SANTA BARBARA\dot SANTA CRUZ }
      \hrule height0.2\[email protected]}}
  \vskip2\[email protected]}

% Mechanism for actually putting the letterhead at the top of the page

\newinsert\letterheadins
% how much to skip when letterhead is present
% \skip\letterheadins72pt (defined in environment)
\count\letterheadins=1000 % length multiplication factor (1 to 1)
\dimen\letterheadins\vsize % maximum letterhead size

\def\@fixindentedwidth{\indentedwidth\textwidth
  \advance\indentedwidth-\longindentation}

\def\@letterhead{% insert letterhead
  \longindentation293\[email protected]
  \advance\@lhdright.5\paperwidth\advance\@lhdright-\oddsidemargin
  \insert\letterheadins{\@tempdima\@lhddown  \advance\@tempdima-\topmargin
    \advance\@tempdima-\headheight  \advance\@tempdima-\headsep
    \vskip\@tempdima
    \moveright\@lhdright\copy\letterhead}%
  {\ifx\@emailcol 0\ifx\@empty\fromaddress\else\let\@emailcol l\fi\fi
    \parindent\[email protected]\parskip\[email protected]\@dotfix
    % make left column
    \setbox0\vbox{\let\\\par\six\baselineskip8pt%
      \ifx\relax\departmentname
        \typeout{No department name given; hope that's OK.}%
      \else\departmentname\par\fi
      \fromlocation\par
      \ifx\@emailcol l \emailfont\baselineskip\emailskip\emailaddr\par\fi}%
    \wd0\longindentation
    % make right column
    \setbox2\vbox{\hsize 211\[email protected]
      {\six\baselineskip8pt%
        \[email protected]\par
        BERKELEY, CALIFORNIA\quad 94720%
          \ifx\frommailcode\@empty\else-\frommailcode\fi\par
        \telephonenum\par}%
      \ifx\@emailcol l\else {\emailfont\baselineskip\emailskip\emailaddr\par}\fi
      \ifx\@empty\fromaddress\else\vskip.5\baselineskip\fromaddress\par\fi
      \today}%
    \insert\letterheadins{%
      \hbox{\hskip\@lhdright\lower\ht0\box0\lower\ht2\box2}}}%
    \advance\longindentation\@lhdright  \@fixindentedwidth}

\def\@noletterhead{\insert\letterheadins{\vskip-36\[email protected]
  \noindent\hspace*{\longindentation}%
  \@fixindentedwidth
  \parbox\indentedwidth{\parindent\[email protected]\parskip\[email protected]\@dotfix\ignorespaces
    \fromaddress\par
    {\advance\emailskip.2\baselineskip\baselineskip\emailskip
      \emailfont\emailaddr\par}%
    \today\par}}}

\def\letterheadanyway{\let\@noletterhead\@letterhead}

\def\@memohead{% insert memohead
  \insert\letterheadins{\def\\{\egroup\hbox\bgroup}%
    \@tempdima\@mhddown  \advance\@tempdima-\topmargin
    \advance\@tempdima-\headheight  \advance\@tempdima-\headsep
    \vskip\@tempdima
    \@tempdima\@mhdright
    \advance\@tempdima.5\paperwidth  \advance\@tempdima-\oddsidemargin
    \hbox to\@tempdima{\hss
      \vbox{{\six\baselineskip8pt%
        \hbox{\llap{BERKELEY:\quad}\departmentname}
        \ifx\@empty\fromlocation\else\hbox{\fromlocation}\fi
        \ifx\@empty\[email protected]\else\hbox{\[email protected]}\fi
        \ifx\@empty\telephonenum\else\hbox{\telephonenum}\fi}%
        \ifx\@empty\emailaddr\else
          {\emailfont\baselineskip\emailskip\hbox{\emailaddr}}\fi
        \vspace{36\[email protected]}\hbox{\today}}}}}

% The following line modified for inclusion of ucb letterhead.

\def\@texttop{\ifvoid\letterheadins\else\unvbox\letterheadins
  \vskip\skip\letterheadins\fi}

% Modify the spacing at the bottom, too, to get better spacing.

\def\@textbottom{\ifnum\[email protected]=1\vskip\[email protected] plus 216\[email protected] minus 24\[email protected]
  \else \vfil \fi}


% THE LETTER ENVIRONMENT

\newif\[email protected]

\renewenvironment{letter}[1]
  {\@autocenter\@fixbottom
    \newpage
    \let\@signed1%
    \[email protected] \ifodd\[email protected]
                \else\thispagestyle{empty} \hbox{}\newpage\fi
    \fi
    \[email protected]\@ne
    \@lettertrue\skip\letterheadins72\[email protected] plus 144\[email protected] minus 54\[email protected]
    \let\subject\@gobble\let\re\@gobble
    \interlinepenalty=200 % smaller than the TeXbook value
    \@processto{\leavevmode\ignorespaces #1}}
  {\stopletter\@@par\pagebreak\@@par
    \[email protected]
      \begingroup
        \let\\=\relax
        \let\protect\@[email protected]
        \immediate\write\@auxout{%
          \string\@mlabel{\returnaddress}{\toname\\\toaddress}}%
      \endgroup
    \fi}


%    ****************************************
%    *         THE UCB MEMO FORMAT          *
%    ****************************************

\newlength{\sbjwid}

% hack for gobbling spaces (some ideas from latex.ltx)
\def\@futureletnext#1{\let\@flt#1\futurelet\next\@flti}
\def\@flti{\ifx\next\@sptoken\let\[email protected]\@fltii\else\let\[email protected]\@flt\fi\[email protected]}
\def\?{\@fltii}  \expandafter\def\? {\futurelet\next\@flti}% defines \@fltii
\let\?\undefined

\newenvironment{memo}[1]
  {\@autocenter\@fixbottom
    \newpage
    \[email protected]\@ne
    \skip\letterheadins72\[email protected]
    \settowidth{\sbjwid}{From:\quad}%
    \pagestyle{memo}\thispagestyle{memo}%
    \interlinepenalty=200 % smaller than the TeXbook value
    \def\toname{#1}%
    \@memohead
    \@futureletnext\@memo} % skips spaces, too
  {\stopletter\@@par\pagebreak\@@par}

\def\@memo{\ifx\next\subject\let\@tempa\@subject
  \else
    \ifx\next\re \let\@tempa\@re \else \let\@tempa\@memotop \fi
  \fi
  \@tempa}

\ifx\@signed1
  \def\@memotop{\par
    \noindent\parbox[t]{\textwidth}{\@dotfix\ignorespaces\toname\strut}\par
    \ifx\@empty\sbjtext\else
      \noindent\parbox[t]{\textwidth}%
        {\@hangfrom{\makebox[\sbjwid][l]{\sbjtext:}}%
        \ignorespaces \sbjbody\strut}\par
    \fi}
\else
  \def\@memotop{\par
    \noindent\parbox[t]{\textwidth}{\@hangfrom{\makebox[\sbjwid][l]{To:}}%
      \@dotfix\ignorespaces\toname\strut}\par
    \noindent\parbox[t]{\textwidth}{\@hangfrom{\makebox[\sbjwid][l]{From:}}%
      \@dotfix\ignorespaces
      \ifx\@empty\fromsig \fromname \else \fromsig \fi\strut}\par
    \ifx\@empty\sbjtext\else
      \noindent\parbox[t]{\textwidth}%
        {\@hangfrom{\makebox[\sbjwid][l]{\sbjtext:}}%
        \ignorespaces \sbjbody\strut}\par
    \fi}
\fi

\def\@subject#1#2{\def\sbjtext{Subject}\def\sbjbody{#2}%
  \settowidth{\sbjwid}{\sbjtext:\quad}%
  \@memotop}
\def\@re#1#2{\def\sbjtext{Re}\def\sbjbody{#2}\@memotop}
\let\sbjtext\@empty

\def\subject#1{\@latexerr{\string\subject\space or \string\re\space macro must
  IMMEDIATELY follow the \string\begin\space macro}{See LATEX local guide.}}
\let\re\subject

% Memo page style.

\def\[email protected]{\let\@oddhead\@empty\def\@oddfoot{\@tempdima\paperwidth
    \advance\@tempdima-2in\relax  \advance\@tempdima-\textwidth
    \advance\@tempdima-2\@themargin  \hskip\@tempdima \hss
    \six UNIVERSITY OF CALIFORNIA---(Letterhead for Interdepartmental Use)\hss}%
  \let\@evenhead\@oddhead\let\@evenfoot\@oddfoot}



%    ****************************************
%    *          MORE DECLARATIVES           *
%    ****************************************

\def\department#1{\def\departmentname{#1}\let\frommailcode\@empty}
\let\departmentname\relax

\def\mailcode#1{\def\frommailcode{#1}}
\let\frommailcode\@empty

\def\upperaddress#1{\def\[email protected]{#1}}
\let\[email protected]\@empty

\let\@emailcol 0
\def\emailatleft{\let\@emailcol l}
\def\emailatright{\let\@emailcol r}
\let\loginatleft\emailatleft    % temporary compatibility fix
\let\loginatright\emailatright

% The following allows use of `@' in the \email string, even with the amstex
% package.
\catcode`\@=\active
\def\email#1{\def\emailaddr{{\[email protected]{\char64\relax}#1}}}
\makeatletter
\let\emailaddr\@empty
\let\login\email           % temporary compatibility fix
\let\emailaddress\email    % temporary compatibility fix

\newif\[email protected]  %\[email protected] (TeX default)
\let\closingatright\[email protected]
\let\closingatleft\[email protected]

% Opening and closing macros.

\renewcommand*{\opening}[1]{%
  \[email protected]
    \thispagestyle{empty}%
    \ifx\@empty\fromaddress\@letterhead \else \@noletterhead \fi
    {\@dotfix\raggedright \ifx\@empty\toname\else\toname \\\fi
      \ifx\@empty\toaddress\else\toaddress\\\vspace{.8\baselineskip}\fi
      \def\next{#1}%
      \ifx\@empty\next\else\ignorespaces#1\\\vspace{.8\baselineskip}\fi
    }\nobreak
  \else  % if memo
    \@fixindentedwidth
  \fi}

\renewcommand{\closing}[1]{\par\nobreak\vspace{\parskip}%
  \stopbreaks
  \ifx\@signed 1%
    \ifnum\[email protected]=1%
      \@tempdima\pagegoal\advance\@tempdima18\[email protected]\pagegoal\@tempdima
    \fi
    \noindent
    \[email protected] \hspace*{\longindentation}\fi
    \parbox{\[email protected]\indentedwidth\else\textwidth\fi}{\@dotfix
         \raggedright
         \ignorespaces #1\\[\sigspace]%
         \ifx\@empty\fromsig
             \fromname
         \else \fromsig \fi\strut}%
    \par
  \fi}

% Fix the spacing in the cc and encl commands.

\renewcommand*{\cc}[1]{%
  \par\noindent\@dotfix
  \parbox[t]{\textwidth}{%
    \@hangfrom{\normalfont\ccname: }%
    \ignorespaces #1\strut}\par}

\renewcommand*{\encl}[1]{%
  \par\noindent\@dotfix
  \parbox[t]{\textwidth}{%
    \@hangfrom{\normalfont\enclname: }%
    \ignorespaces #1\strut}\par}

% Redefine \stopletter to get better spacing.

\def\stopletter{\vskip\[email protected] plus 3in}
% Installation dependent options.

\department{DEPARTMENT OF MATHEMATICS}
\mailcode{3840}

\endinput