% \iffalse meta-comment -*- Mode: LaTeX; coding: ascii; -*-
%       $Id: facsimile.dtx,v 1.11 2003/04/25 16:54:49 bronger Exp bronger $    
%
%     facsimile.dtx - Package for writing faxes
%     Copyright 2003 Torsten Bronger
%                    <bronger@users.sourceforge.net>
%
%   This program may be distributed and/or modified under the
%   conditions of the LaTeX Project Public License, either version 1.2
%   of this licence or (at your option) any later version.
%   The latest version of this licence is in
%     http://www.latex-project.org/lppl.txt
%   and version 1.2 or later is part of all distributions of LaTeX
%   version 1999/12/01 or later.
%
% \fi
%
% \CheckSum{732}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
%
% \DoNotIndex{\@@par,\@M,\@bsphack,\@cdr,\@esphack,\@ifstar,\@ifundefined}
% \DoNotIndex{\@nil,\@nobreakcr,\@nobreakvspace,\@nobreakvspacex,\@normalcr}
% \DoNotIndex{\@tempboxa,\@tempdima,\@tempdimb,\ ,\\,\,,\addto,\addtolength}
% \DoNotIndex{\advance,\begin,\begingroup,\csname,\DeclareRobustCommand}
% \DoNotIndex{\def,\else,\emph,\end,\endcsname,\endgroup,\expandafter}
% \DoNotIndex{\fi,\gdef,\hbadness,\hbox,\hskip,\hss,\ht,\ifdim}
% \DoNotIndex{\ifx,\leavevmode,\let,\mbox,\medskipamount,\newcommand}
% \DoNotIndex{\newdimen,\nobreak,\p@,\par,\relax,\renewcommand,\setbox}
% \DoNotIndex{\setlength,\unhbox,\vbox,\vskip,\vspace}
% \DoNotIndex{\IfFileExists,\makeatletter,\makeatother}
% \DoNotIndex{\ifmathptmx,\mathptmxtrue,\mathptmxfalse,\newif,\providecommand}
% \DoNotIndex{\usepackage,\@undefined,\oldurl,\dots,\message,\url}
%
% \newcommand*{\mboxtt}[1]{\texttt{\mbox{#1}}}
%
% \def\fileversion{v1.1}
% \def\filedate{2003/04/25}
%
% \title{The \mboxtt{facsimile} package\thanks{This file
%        has version number \fileversion, last
%        revised \filedate.}}
% \author{Torsten Bronger\\
%         \ifpdflatex
%         \url{mailto:bronger@users.sourceforge.net}
%         \else
%         \url{bronger@users.sourceforge.net}\fi}
%
% \maketitle
%
% \begin{abstract}
% The \mboxtt{facsimile} package provides a simple interface for creating a
% fax.  This covers by and large two areas: First, a title page is created with
% a detailed fax header.  And secondly, every page gets headers and footers so
% that the recipient can be sure to have received all pages and complete
% pages, and to have the correct order.
% \end{abstract}
%
% \tableofcontents
%
% \section*{The documentation driver file}
%
% This section is purely technical and for the usage of \mboxtt{facsimile}
% totally meaningless.  Please read further at ``Installation''
% \vpageref[below]{sec:installation}.
%
% \bigskip
% The next bit of code contains the documentation driver file for
% \TeX, i.\,e., the file that will produce the documentation you are
% currently reading.  It will be extracted from this file by the
% \texttt{docstrip} program.  Since it is the first code in the file
% one can alternatively process this file directly with \LaTeXe{} to
% obtain the documentation.
%
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\OnlyDescription

\newif\ifmathptmx
\IfFileExists{mathptmx.sty}{\mathptmxtrue}{\mathptmxfalse}
\ifmathptmx\usepackage{mathptmx}\usepackage{courier}\fi
\usepackage[latin1]{inputenc}\usepackage{varioref}
\usepackage{url}\providecommand*{\url}[1]{\texttt{\mbox{#1}}}
\let\oldurl=\url
\newif\ifpdflatex\makeatletter\ifx\pdfoutput\@undefined
\pdflatexfalse\else\pdflatextrue\fi\makeatother
\ifpdflatex
\usepackage[%
  pdftex,pagebackref=true,pdfstartview=FitH,
  pdftitle={The facsimile package},
  pdfauthor={Torsten Bronger},
  pdfkeywords={LaTeX,package,fax,facsimile},
  pdfpagelayout=OneColumn,
  pdfpagelabels=true,
  draft=false,plainpages=false]{hyperref}[2000/05/08]
\fi

\EnableCrossrefs
\CodelineIndex

\begin{document}
   \DocInput{facsimile.dtx}
   \PrintIndex
\end{document}
%</driver>
%    \end{macrocode}
%
% \section{Installation}
% \label{sec:installation}
%
% The distribution consists of just two files, \mboxtt{facsimile.dtx} and
% \mboxtt{facsimile.ins}.  The installation is totally typical of a \LaTeXe\
% package: Call
%\begin{verbatim}
%  tex facsimile.ins
%\end{verbatim}
% and move the resulting file \mboxtt{facsimile.cls} where \TeX\ can find it.  In a
% TDS conformant system, you should put it e.\,g.\ in the directory
% \oldurl{texmf/tex/latex/facsimile}.  Then update \TeX's filename database.
% You get this documentation with
%\begin{verbatim}
%  latex facsimile.dtx
%\end{verbatim}
% (If you want to see the implementation, too, comment out the |\OnlyDescription|
% command in the DTX file.)
% 
% \subsection{The configuration file}
%
% You should consider creating a configuration file called \mboxtt{facsimile.cfg}.
% Then you have the same font setup, sender's address, and more for all your
% faxes, and you don't have to set this explicitly in every single fax.  Of
% course, you can also load some additional packages and set page margins and
% things like that.
%
% It is by and large unimportant where you place this file.  It is only
% important that \TeX\ can find it.  Since it contains personal information, it
% should not be global, but placed where it is only read from your account,
% e.\,g.\ in your local \texttt{texmf} tree.  If you are the only person who
% uses the computer, this is insignificant though.
%
% By using e.\,g.\ Babel you can make your configuration file language
% sensitive.  This can be useful if you write faxes to people in different
% languages.
% 
% \section{Usage}
%
% \subsection{Configuration file commands}
%
% You can use the following commands either in the configuration file
% \mboxtt{facsimile.cfg} or in the preamble of your document.  However, in the
% configuration file they are more useful.
% 
% \DescribeMacro\faxfrom
% The macro |\faxfrom{|\meta{sender}|}| takes as the only parameter \LaTeX\
% code that produces information about the sender of the fax.  It may be filled
% with something like this: 
%\begin{verbatim}
%  \faxfrom{%
%    \begin{tabular}{rl}
%    from:        & Bugs Bunny\\
%    address:     & ACME Street 42\\
%                 & 90210 Toontown\\
%                 & USA\\
%    phone/fax:   & +1-555-314159\\
%    \end{tabular}}
%\end{verbatim}
%
% \DescribeMacro\faxheaderfont
% The fax header will be typeset in the same font as the rest of the document.
% In particular, any global font changes you make in your document preamble
% will be visible in the fax header, too.  But if you want to use a special
% font in the fax header, put the font activating commands in |\faxheaderfont|
% with e.\,g.
%\begin{verbatim}
%  \renewcommand{\faxheaderfont}{\fontfamily{phv}\selectfont}
%\end{verbatim}
% which activates Helvetica.
%
% \DescribeMacro\faxnotetext
% If this macro contains text, it is printed as a note on the cover page.  For
% example, you may set it to
%\begin{verbatim}
%  \renewcommand{\faxnotetext}{This message was sent using a fax
%    modem.  When replying to this fax, phone first, so the fax
%    modem and PC can be switched on and prepared for fax
%    reception.}
%\end{verbatim}
% 
% \DescribeMacro\fromsig
% By default, the author's name is printed below the empty space where you can
% insert your signature.  If you set |\fromsig|, its contents is used instead.
%
% \DescribeMacro{\closinghook}
% Obviously it's silly to sign a fax if it's sent purely electronically.  But
% you can scan your own signature and say
%\begin{verbatim}
%  \renewcommand{\closinghook}{\includegraphics{signature}\\}
%\end{verbatim}
% Then the graphics with the file name \mboxtt{signature.eps}\footnote{The
% exact file name extension depends on your dvi driver.} is printed between the
% closing phrase and your name.  Of course, you then have to load the
% \mboxtt{graphics} package, too.  This is a mere example application of
% |\closinghook|; you may put in it (almost) whatever you want.
% 
% \subsection{Preamble commands}
% 
% The following commands are used in your document \emph{before}
% |\begin{document}|.
% 
% \DescribeMacro\faxto
% The counterpart of |\faxfrom| for the recipient is
% |\faxto{|\meta{recipient}|}|.  For example:
%\begin{verbatim}
%  \faxto{%
%    \begin{tabular}{rl}
%    to:          & \textbf{The President}\\
%    fax:         & +1-202-456-1414\\
%    \end{tabular}}
%\end{verbatim}
%
% \DescribeMacro\faxsubject
% You \emph{must} set a subject for your fax with
% \begin{quote}
% |\faxsubject[|\meta{short subject}|]{|\meta{subject}|}|
% \end{quote}
% The short subject is optional and used for the page headers.
%
% \subsection{Document commands}
%
% You can use the following commands between |\begin{document}| and
% |\end|\hskip0pt|{document}|.
% 
% \DescribeMacro\makefaxtitle
% The fax header is not produced implicitly.  You trigger it with
% |\makefaxtitle|.  Normally this is the very first command in your document.
%
% \DescribeMacro\opening
% This is used exactly as in the \mboxtt{letter} class:
% |\opening{|\meta{greeting phrase}|}|.  It starts the text body of your fax.
%
% \DescribeMacro\closing
% This is used exactly as in the \mboxtt{letter} class:
% |\closing{|\meta{closing phrase}|}|.  It ends the text body of your fax.
%
% \section{Complete example}
%
% \subsection{An example for \mboxtt{facsimile.cfg}}
%
% A configuration file can be very simple.  Only two things are really
% necessary: The |\faxfrom| call and the |\author| call.
%
% When you unpack the \mboxtt{facsimile} package, this short example is written
% to the file \mboxtt{fac-en.cfg}.  Take it as templates for your own
% configuration.\footnote{Of course your configuration file must be called
% \mboxtt{facsimile.cfg} so that it works.}
%    \begin{macrocode}
%<*coreconfiguration>
\faxfrom{%
  \begin{tabular}{rl}
  from:        & Bugs Bunny\\
  address:     & ACME Street 42\\
               & 90210 Toontown\\
               & USA\\
  phone/fax:   & +1-555-314159\\
  \end{tabular}}

\author{Bugs Bunny}
%</coreconfiguration>
%    \end{macrocode}
%
% \subsubsection{A not so simple example configuration}
% 
% This alternative configuration file shows how language sensitiveness can be
% realised:  It works for both English and German faxes.
%
% When you unpack the \mboxtt{facsimile} package, this long example is written
% to the file \mboxtt{fac-de.cfg}.  You can use that as a starting point for
% your personal \mboxtt{facsimile.cfg} as well.
%
% Please note that it's wise to avoid non-ASCII characters in such
% configuration files.  Therefore I don't write ``\mboxtt{straße}'' but
% ``\verb|stra\ss e|''.
%
%    \begin{macrocode}
%<*configuration>
\makeatletter
\@ifpackageloaded{babel}{}{
  \renewcommand{\iflanguage}[3]{%
    \def\paramone{german}\def\paramtwo{#1}
    \ifx\paramone\paramtwo\else
      \errmessage{internal error in facsimile.cfg}\fi
    \@ifpackageloaded{german}{#2}{#3}}
}
\makeatother

\iflanguage{german}{
%    \end{macrocode}
% This is the German variant of the fax header.
%    \begin{macrocode}
\renewcommand{\faxnotetext}{Dieses Fax wurde von einem
  Faxmodem aus gesendet.  Wenn Sie auf dieses Fax antworten
  wollen, rufen Sie erst an, damit sichergestellt werden kann,
  da\ss{} das Faxmodem bereit ist, die Sendung zu empfangen.}

\faxfrom{%
  \begin{tabular}{rl}
  von:         & Peter Meier\\
  Adresse:     & Hauptstra\ss e 7\\
               & 28182 Musterstadt\\
  Telefon/Fax: & 08\,67\,/\,65\,53\,4\\
  \end{tabular}}
}{
%    \end{macrocode}
% And this is the English variant of the fax header.
%    \begin{macrocode}
\renewcommand{\faxnotetext}{This message was sent using a fax
  modem. When replying to this fax, phone first, so the fax
  modem and PC can be switched on, and prepared for fax
  reception.}

\faxfrom{%
  \begin{tabular}{rl}
  from:        & Peter Meier\\
  address:     & Hauptstra\ss e 7\\
               & 27182 Musterstadt\\
               & Germany\\
  phone/fax:   & +49-867-65534\\
  \end{tabular}}
}

%    \end{macrocode}
% I switch to the Helvetica font for the faxes.  The \mboxtt{mathptmx}
% inclusion is for nicer mathematics.
%    \begin{macrocode}
\usepackage{mathptmx}\boldmath
\usepackage{helvet}
\renewcommand{\rmdefault}{\sfdefault}\rmfamily

%    \end{macrocode}
% Here I include a scanned signature as a picture into the fax.  It must be
% saved as \mboxtt{signature.eps}.
%    \begin{macrocode}
\IfFileExists{signatur.eps}{
  \usepackage[dvips]{graphicx}
  \renewcommand{\closinghook}{\includegraphics{signatur}\\}
}
{
  \message{signatur.eps not found!}
}

\author{Peter Meier}
%</configuration>
%    \end{macrocode}
%
% \subsection{An example document}
%
% I don't want to interrupt this example document with comments so that you can
% grasp its structure better.
%
% When you unpack \mboxtt{facsimile}, this example is written to the file
% \mboxtt{example.tex}.
% 
%    \begin{macrocode}
%<*example>
\documentclass{facsimile}

\faxsubject{Curriculum vitae}
\faxto{%
  \begin{tabular}{rl}
  to:          & \textbf{The President}\\
  fax:         & +1-202-456-1414\\
  \end{tabular}}

\begin{document}
 \makefaxtitle

 \opening{Dear Mr.~President,}

 I submit my curriculum vitae as arranged by phone.

 [\dots]
 
 \closing{Yours most sincerely}

\end{document}
%</example>
%    \end{macrocode}
%
% \subsubsection{German fax example}
%
% It is in German to show non-English usage exemplarily, however by and large
% the only special line is the inclusion of the Babel package.  The inclusion
% of the \mboxtt{fontenc} and \mboxtt{inputenc} packages is also especially
% useful for non-English material.  For Windows, substitute ``|ansinew|'' for
% ``|latin1|''. 
%
%\begin{verbatim}
%  \documentclass{facsimile}
% 
%  \usepackage[T1]{fontenc}
%  \usepackage[latin1]{inputenc}
%  \usepackage[german]{babel}
% 
%  \faxsubject{Lebenslauf}
%  \faxto{%
%    \begin{tabular}{rl}
%    an:          & \textbf{Paul Schmidt}\\
%    Fax:         & 0367/87944\\
%    \end{tabular}}
% 
%  \begin{document}
%   \makefaxtitle
% 
%   \opening{Sehr geehrter Herr Schmidt,}
% 
%   hiermit schicke ich Ihnen meinen Lebenslauf, wie telefonisch
%   vereinbart.
%
%   [\dots]
%  
%   \closing{Mit freundlichen Grüßen}
% 
%  \end{document}
%\end{verbatim}
%
% \StopEventually{}
%
% \section{Self identification of \mboxtt{facsimile}}
%
%    \begin{macrocode}
%<*facsimile>
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{facsimile}[2003/04/25 v1.1 Fax class (TBr)]
%    \end{macrocode}
% \begin{macro}{\@emptyauthor}
% I save the empty author macro in |\@emptyauthor| to have something to test
% whether |\author| is set or not.  This is used in section~\ref{Headers} on
% page~\pageref{Headers}.
%    \begin{macrocode}
\let\@emptyauthor=\@author
%    \end{macrocode}
% \end{macro}
% 
%
% \section{Language dependent stuff}
%
% \mboxtt{facsimile} needs some words in a human language that are not part of
% Babel.  I define macros of the form |\f@x|\meta{language} that set the values
% for the respective language.
%
% If you can provide such snippets for another language, please send them to
% the \mboxtt{facsimile} maintainer.
%
% \begin{macro}{\iff@xlanguageset}
% This switch is |true| if a language has been chosen by a global option.
%    \begin{macrocode}
\newif\iff@xlanguageset\f@xlanguagesetfalse
%    \end{macrocode}
% \end{macro}
%
% \subsection{Afrikaans}
%
% Provided by Els DNJ (\url{mailto:dnjels@sun.ac.za}).
%
% \begin{macro}{\f@xafrikaans}
%    \begin{macrocode}
\newcommand{\f@xafrikaans}{%
  \def\datename{datum}%
  \def\onepagename{bladsy}%
  \def\pagesname{bladsye}%
  \def\notename{nota}%
  \def\ofname{van}%
  \def\fromname{van}%
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\DeclareOption{afrikaans}{\f@xafrikaans\f@xlanguagesettrue}
%    \end{macrocode}
% 
% \subsection{Dutch}
%
% Provided by Steven Van Hove
% (\url{mailto:steven.vanhove@student.kuleuven.ac.be}).
%
% \begin{macro}{\f@xdutch}
%    \begin{macrocode}
\newcommand{\f@xdutch}{%
  \def\datename{datum}%
  \def\onepagename{bladzijde}%
  \def\pagesname{bladzijden}%
  \def\notename{opmerking}%
  \def\ofname{van}%
  \def\fromname{van}%
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\DeclareOption{dutch}{\f@xdutch\f@xlanguagesettrue}
%    \end{macrocode}
%
% \subsection{English}
%
% \begin{macro}{\f@xenglish}
%    \begin{macrocode}
\newcommand{\f@xenglish}{%
  \def\datename{date}%
  \def\onepagename{page}%
  \def\pagesname{pages}%
  \def\notename{note}%
  \def\ofname{of}%
  \def\fromname{from}%
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\DeclareOption{english}{\f@xenglish\f@xlanguagesettrue}
\DeclareOption{USenglish}{\f@xenglish\f@xlanguagesettrue}
\DeclareOption{american}{\f@xenglish\f@xlanguagesettrue}
\DeclareOption{UKenglish}{\f@xenglish\f@xlanguagesettrue}
\DeclareOption{british}{\f@xenglish\f@xlanguagesettrue}
\DeclareOption{canadian}{\f@xenglish\f@xlanguagesettrue}
%    \end{macrocode}
%
% \subsection{French}
%
% Provided by Enrico Riboni (\url{mailto:eriboni@ozone.ch}).
%
% \begin{macro}{\f@xfrench}
%    \begin{macrocode}
\newcommand{\f@xfrench}{%
  \def\datename{date}%
  \def\pagename{page}%
  \def\pagesname{pages}%
  \def\notename{note}%
  \def\ofname{de}%
  \def\fromname{de}%
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\DeclareOption{french}{\f@xfrench\f@xlanguagesettrue}
\DeclareOption{frenchb}{\f@xfrench\f@xlanguagesettrue}
%    \end{macrocode}
%
% \subsection{German}
%
% \begin{macro}{\f@xgerman}
%    \begin{macrocode}
\newcommand{\f@xgerman}{%
  \def\datename{Datum}%
  \def\onepagename{Seite}%
  \def\pagesname{Seiten}%
  \def\notename{Bemerkung}%
  \def\ofname{von}%
  \def\fromname{von}%
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\DeclareOption{german}{\f@xgerman\f@xlanguagesettrue}
\DeclareOption{germanb}{\f@xgerman\f@xlanguagesettrue}
\DeclareOption{ngerman}{\f@xgerman\f@xlanguagesettrue}
\DeclareOption{austrian}{\f@xgerman\f@xlanguagesettrue}
\DeclareOption{naustrian}{\f@xgerman\f@xlanguagesettrue}
%    \end{macrocode}
%
% \subsection{Italian}
%
% FixMe: These translations (especially the last two) need to be checked.
%
% \begin{macro}{\f@xitalian}
%    \begin{macrocode}
\newcommand{\f@xitalian}{%
  \def\datename{data}%
  \def\onepagename{pagina}%
  \def\pagesname{pagine}%
  \def\notename{nota}%
  \def\ofname{di}%
  \def\fromname{da}%
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\DeclareOption{italian}{\f@xitalian\f@xlanguagesettrue}
%    \end{macrocode}
%
% \subsection{Portuguese}
%
% Provided by jvilhena (\url{mailto:jvilhena@softhome.net}).
%
% \begin{macro}{\f@xportuges}
%    \begin{macrocode}
\newcommand{\f@xportuges}{%
  \def\datename{data}%
  \def\onepagename{p\'agina}%
  \def\pagesname{p\'aginas}%
  \def\notename{nota}%
  \def\ofname{de}%
  \def\fromname{de}%
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\DeclareOption{portuges}{\f@xportuges\f@xlanguagesettrue}
\DeclareOption{portuguese}{\f@xportuges\f@xlanguagesettrue}
\DeclareOption{brazilian}{\f@xportuges\f@xlanguagesettrue}
\DeclareOption{brazil}{\f@xportuges\f@xlanguagesettrue}
%    \end{macrocode}
%
% \subsection{Spanish}
%
% Provided by Victor Lua\~na Cabal
% (\url{mailto:victor@fluor.quimica.uniovi.es}).
%
% \begin{macro}{\f@xspanish}
%    \begin{macrocode}
\newcommand{\f@xspanish}{%
  \def\datename{fecha}%
  \def\onepagename{p\'agina}%
  \def\pagesname{p\'aginas}%
  \def\notename{nota}%
  \def\ofname{de}%
  \def\fromname{de}%
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\DeclareOption{spanish}{\f@xspanish\f@xlanguagesettrue}
%    \end{macrocode}
% 
% \subsection{Swedish}
%
% Provided by Ozan \"Oktem (\url{mailto:08-295825@telia.com}).
%
% \begin{macro}{\f@xswedish}
%    \begin{macrocode}
\newcommand{\f@xswedish}{%
  \def\datename{datum}%
  \def\onepagename{sida}%
  \def\pagesname{sidor}%
  \def\notename{notering}%
  \def\ofname{av}%
  \def\fromname{fr\aa n}%
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\DeclareOption{swedish}{\f@xswedish\f@xlanguagesettrue}
%    \end{macrocode}
%
%
% \subsection{Default values}
%
% \begin{macro}{\datename}
% \begin{macro}{\onepagename}
% \begin{macro}{\pagesname}
% \begin{macro}{\notename}
% \begin{macro}{\ofname}
% \begin{macro}{\fromname}
% I define the default values for the text strings that are needed by
% \mboxtt{facsimile}. They are the English values of course.  I don't use
% |\f@xenglish| for this in order to assure these values haven't been already
% defined.
%
%    \begin{macrocode}
\newcommand{\datename}{date}
\newcommand{\onepagename}{page}
\newcommand{\pagesname}{pages}
\newcommand{\notename}{note}
\newcommand{\ofname}{of}
\newcommand{\fromname}{from}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Support for Babel and \texttt{german.sty}}
%
% At the beginn of the document I test whether Babel is active.  If it is, I
% add the supported languages to Babel's language machanism.  Then Babel's
% active language determines which language \mboxtt{facsimile} chooses.
%
% If Babel is not loaded, I first test whether a language has been chosen via a
% global option (|\iff@xlanguageset|).  If not, I activate German language if
% the \mboxtt{german.sty} package was loaded.
%
% So the order of precedence is: Babel $\to$ global option $\to$
% \mboxtt{german.sty} $\to$ default (English).
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{babel}{%
    \addto\extrasafrikaans{\f@xafrikaans}%
    %
    \addto\extrasdutch{\f@xdutch}%
    %
    \addto\extrasenglish{\f@xenglish}%
    \addto\extrasUSenglish{\f@xenglish}%
    \addto\extrasamerican{\f@xenglish}%
    \addto\extrasUKenglish{\f@xenglish}%
    \addto\extrasbritish{\f@xenglish}%
    \addto\extrascanadian{\f@xenglish}%
    %
    \addto\extrasfrench{\f@xfrench}%
    \addto\extrasfrancais{\f@xfrench}%
    \addto\extrascanadien{\f@xfrench}%
    \addto\extrasacadian{\f@xfrench}%
    %
    \addto\extrasgerman{\f@xgerman}%
    \addto\extrasngerman{\f@xgerman}%
    \addto\extrasaustrian{\f@xgerman}%
    \addto\extrasnaustrian{\f@xgerman}%
    %
    \addto\extrasitalian{\f@xitalian}%
    %
    \addto\extrasportuges{\f@xportuges}%
    \addto\extrasportuguese{\f@xportuges}%
    \addto\extrasbrazilian{\f@xportuges}%
    \addto\extrasbrazil{\f@xportuges}%
    %
    \addto\extrasspanish{\f@xspanish}%
    %
    \addto\extrasswedish{\f@xswedish}%
  }{\iff@xlanguageset\else
    \@ifpackageloaded{german}{\f@xgerman}{%
      \@ifpackageloaded{ngerman}{\f@xgerman}{%
      }}\fi}%
}
%    \end{macrocode}
%
% \section{Processing the class options}
%
% \begin{macro}{\f@xfontsize}
% The default font size for faxes it 12\,pt.  This macro may be reset by a
% global class option.
%    \begin{macrocode}
\newcommand{\f@xfontsize}{12pt}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\f@xbaseclassname}
% The default class that \mboxtt{facsimile} relies on is \mboxtt{article}.  The
% \mboxtt{koma} option resets this macro.
%    \begin{macrocode}
\newcommand{\f@xbaseclassname}{article}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Font size option}
%
%    \begin{macrocode}
\DeclareOption{10pt}{\renewcommand{\f@xfontsize}{10pt}}
\DeclareOption{11pt}{\renewcommand{\f@xfontsize}{11pt}}
\DeclareOption{12pt}{\renewcommand{\f@xfontsize}{12pt}}
%    \end{macrocode}
%
% \subsection{Support for KOMA}
%
% With this option you can use KOMA's \mboxtt{scrartcl} instead of \LaTeX's
% \mboxtt{article}.  All other global options are passed to \mboxtt{scrartcl}
% in this case.
%
%    \begin{macrocode}
\DeclareOption{koma}{\renewcommand{\f@xbaseclassname}{scrartcl}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}%
                                   {\f@xbaseclassname}}
%    \end{macrocode}
%
% \subsection{Option processing}
% 
%    \begin{macrocode}
\ExecuteOptions{12pt}
\ProcessOptions\relax
\LoadClass[\f@xfontsize]{\f@xbaseclassname}
%    \end{macrocode}
%
% \section{Fax header contents}
%
% \begin{macro}{\faxnotetext}
% This is empty by default but you may set it to an arbitrary text.  For
% example it can contain a warning that a reply to your fax must be announced
% before, because you first have to switch your computer on.
%    \begin{macrocode}
\newcommand{\faxnotetext}{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\f@xsubject}
% \begin{macro}{\f@xsubjectshort}
% \begin{macro}{\f@xfrom}
% \begin{macro}{\f@xto}
% These macros are the internal variables for the fields in the fax header.  By
% default, they contain code that generates error messages for the user,
% because the user \emph{must} explicitly set those fields.
%    \begin{macrocode}
\newcommand{\f@xsubject}{\ClassError{facsimile}%
  {No fax subject given}{}\textbf{??}}
\newcommand{\f@xsubjectshort}{\textbf{??}}
\newcommand{\f@xfrom}{\ClassError{facsimile}%
  {No fax sender given}{}
  \gdef\f@xfrom{from:&\textbf{??}\\}\f@xfrom}
\newcommand{\f@xto}{\ClassError{facsimile}%
  {No fax recipient given}{}
  \gdef\f@xto{to:&\textbf{??}\\}\f@xto}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{User interface}
%
% The user sets the above variables by calling these macros.
%
% \begin{macro}{\faxsubject}
% This sets the subject of the fax.  It is printed as the title on the cover
% page and in the head line on all other pages.
%    \begin{macrocode}
\newcommand*{\faxsubject}[2][\f@xsubject]{
  \renewcommand{\f@xsubject}{#2}
  \renewcommand{\f@xsubjectshort}{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\faxto}
% This sets the ``\textit{to:}''\ field in the fax header.  It may be a box or
% a table.
%    \begin{macrocode}
\newcommand*{\faxto}[1]{\renewcommand{\f@xto}{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\faxfrom}
% This sets the ``\textit{from:}''\ field in the fax header.  It may be a box
% or a table.
%    \begin{macrocode}
\newcommand*{\faxfrom}[1]{\renewcommand{\f@xfrom}{#1}}
%    \end{macrocode}
% \subsubsection{Configuration file}
% Here I read a configuration file called \mboxtt{facsimile.cfg} if it exists.  It
% may set a default |\author|, |\faxfrom|, and |\faxheaderfont|.  It may even
% do so language sensitive.
%    \begin{macrocode}
\AtBeginDocument{%
  \InputIfFileExists{facsimile.cfg}{\ClassInfo{facsimile}%
    {Loading configuration file facsimile.cfg}}{}}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Determining the number of pages}
%
% For this I use the |lastpage| package.
%    \begin{macrocode}
\RequirePackage{lastpage}
%    \end{macrocode}
% \begin{macro}{\@lstpgno}
% I stole this command from the \texttt{fax} package.  I don't know how it
% works, but it yields the number of pages or zero if it couldn't be
% determined.
%    \begin{macrocode}
\newcommand*{\@lstpgno}{%
  \@ifundefined{r@LastPage}{0}{%
    \expandafter\expandafter\expandafter
    \@cdr\csname r@LastPage\endcsname
    \@nil}%
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Setting style}
%
% \begin{macro}{\faxheaderfont}
% You can override this definition in order to get your favourite font for the
% fax header.
%    \begin{macrocode}
\newcommand{\faxheaderfont}{\sffamily}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\f@xboxgap}
% \begin{macro}{\f@xboxsep}
% \begin{macro}{\f@xframethickness}
% You can reset these three macros, too, however the default values seem very
% reasonable to me.  |\f@xgap| is the gap between the header boxes whereas
% |\f@xsep| is the separation between the box and its contents.
% |\f@xframethickness| is the line width of the box frames.
%    \begin{macrocode}
\newdimen\f@xboxgap \setlength{\f@xboxgap}{1mm}
\newdimen\f@xboxsep \setlength{\f@xboxsep}{2mm}
\newdimen\f@xframethickness \setlength{\f@xframethickness}{0.3mm}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \section{Creating the header layout}
%
% \begin{macro}{\f@xframebox}
% This creates one framed box on the cover page.  The first parameter~|#2| is
% the width of the box, the second parameter~|#3| is its contents.  An optional
% parameter~|#1| sets the height of the box explicitly.  If given, it must be
% of the form ``|to 30pt|'' for example.
%    \begin{macrocode}
\newcommand{\f@xframebox}[3][]{\hbox to #2{%
    \vrule width \f@xframethickness
    \vbox{\hrule height \f@xframethickness
      \vskip\f@xboxsep
      \hbox{\hskip\f@xboxsep
        \setlength{\@tempdima}{#2}%
        \addtolength{\@tempdima}{-2\f@xboxsep}%
        \addtolength{\@tempdima}{-2\f@xframethickness}%
        \setlength{\hsize}{\@tempdima}%
        \vbox #1{\vbox{#3}\vfill}\hskip\f@xboxsep}%
      \vskip\f@xboxsep
      \hrule height \f@xframethickness}%
    \vrule width \f@xframethickness}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\f@xdoubleframebox}
% This sets \emph{two} of such boxes next to each other.  It has two
% parameters that are simply the contents of both boxes.  It assures that both
% boxes have the same height so that they are vertically neatly aligned.
%    \begin{macrocode}
\newcommand{\f@xdoubleframebox}[2]{\hbox to \hsize{%
%    \end{macrocode}
% |\@tempdima| should eventually have the (inner) width of the contents of one
% box.
%    \begin{macrocode}
    \setlength{\@tempdima}{0.5\hsize}%
    \addtolength{\@tempdima}{-0.5\f@xboxgap}%
%    \end{macrocode}
% |\@tempdimb| should eventual have the (outer) width of one box.
%    \begin{macrocode}
    \setlength{\@tempdimb}{\@tempdima}%
    \addtolength{\@tempdima}{-2\f@xboxsep}%
    \addtolength{\@tempdima}{-2\f@xframethickness}%
    \setlength{\hsize}{\@tempdima}%
%    \end{macrocode}
% Here I create two \TeX\ boxes with the respective contents.
%    \begin{macrocode}
    \newbox\fr@meleft \newbox\fr@meright
    \setbox\fr@meleft=\vbox{\vbox{#1}\hrule height 0pt}%
    \setbox\fr@meright=\vbox{\vbox{#2}\hrule height 0pt}%
%    \end{macrocode}
% |\maxfr@meheight| is the height of the higher box.
%    \begin{macrocode}
    \newdimen\maxfr@meheight
    \setlength{\maxfr@meheight}{\ht\fr@meleft}%
    \ifdim\maxfr@meheight<\ht\fr@meright
      \setlength{\maxfr@meheight}{\ht\fr@meright}%
    \fi
%    \end{macrocode}
% Finally, print both boxes.
%    \begin{macrocode}
    \f@xframebox[to \maxfr@meheight]{\@tempdimb}{#1}%
    \hskip\f@xboxgap
    \f@xframebox[to \maxfr@meheight]{\@tempdimb}{#2}%
  }}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\makefaxtitle}
% This is a user command.  It is \mboxtt{facsimile}'s pendant to \LaTeX's
% |\matketitle|.
%    \begin{macrocode}
\newcommand{\makefaxtitle}{\begingroup
%    \end{macrocode}
% First, I set the font and avoid wrong skips.
%    \begin{macrocode}
  \faxheaderfont\parskip0pt\parindent0pt
%    \end{macrocode}
% Here comes the subject.  It's the title of a fax.
%    \begin{macrocode}
  \centerline{\LARGE\bfseries\f@xsubject}\vskip2ex
%    \end{macrocode}
% |\halff@xboxwidth| is the (outer) width of one header box.
%    \begin{macrocode}
  \newdimen\halff@xboxwidth
  \setlength{\halff@xboxwidth}{0.5\hsize}
  \addtolength{\halff@xboxwidth}{-0.5\f@xboxgap}
%    \end{macrocode}
% This |\vbox| will contain the whole header.  It has the following structure:
% First two ``double'' boxes with recipient, sender, date, and number of pages,
% respectively.  The an optional box of full width with a note.
%    \begin{macrocode}
  \vbox{%
    \f@xdoubleframebox{\f@xto}{\f@xfrom}%
    \nointerlineskip\vskip\f@xboxgap
    \f@xdoubleframebox{%
      \centerline{\textbf{\expandafter
          \MakeUppercase\datename:}\quad\@date}}%
    {%
      \centerline{\textbf{Fax:}\quad
        \pageref{LastPage}~\ifcase\@lstpgno \pagesname
        \or \onepagename \else \pagesname \fi}}%
    \nointerlineskip\vskip\f@xboxgap
    \ifx\faxnotetext\@empty\else
      \f@xframebox{\hsize}{%
        \setbox\@tempboxa\hbox{\textbf{\expandafter
            \MakeUppercase\notename:}}%
        \@tempdima=\ht\@tempboxa
        \framebox{\vrule height \@tempdima width 0pt%
          \smash{\unhbox\@tempboxa}}%
        \hskip1em plus 0.2em\sloppy\hbadness10000\faxnotetext}%
    \fi
  }\endgroup}
%    \end{macrocode}
% \end{macro}
%
% \section{Mimicry of \LaTeX's \mboxtt{letter} class}
%
% \subsection{Setting paragraph skips and more}
%
%    \begin{macrocode}
\setlength\parskip{0.7em}
\setlength\parindent{0\p@}
%    \end{macrocode}
% \begin{macro}{\longindentation}
% \begin{macro}{\indentedwidth}
% They are used by |closing|.
%    \begin{macrocode}
\newdimen\longindentation
\longindentation=.5\textwidth
\newdimen\indentedwidth
\indentedwidth=\textwidth
\advance\indentedwidth -\longindentation
%    \end{macrocode}
% \end{macro}
%
% \subsection{Opening and closing}
% 
% \end{macro}
% \begin{macro}{\opening}
% This is by and large a stripped version of the command of the same name in
% \LaTeX's \mboxtt{letter} class.
%    \begin{macrocode}
\newcommand*{\opening}[1]{\vspace{2\parskip}%
  #1\par\nobreak\vspace{0.5\parskip}\nobreak}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\stopbreaks}
% This is used in |\closing|.  It is copied from \mboxtt{letter.cls}.
%    \begin{macrocode}
\newcommand*{\stopbreaks}{%
  \interlinepenalty\@M
  \def\par{\@@par\nobreak}%
  \let\\\@nobreakcr
  \let\vspace\@nobreakvspace}
%    \end{macrocode}
% \end{macro}
% The following code is copied from \mboxtt{letter.cls}.
%    \begin{macrocode}
\DeclareRobustCommand\@nobreakvspace
   {\@ifstar\@nobreakvspacex\@nobreakvspacex}
\def\@nobreakvspacex#1{%
  \ifvmode
    \nobreak\vskip #1\relax
  \else
    \@bsphack\vadjust{\nobreak\vskip #1}\@esphack
  \fi}
\def\@nobreakcr{\@ifstar{\@normalcr*}{\@normalcr*}}
%    \end{macrocode}
% \begin{macro}{\fromsig}
% This is used in |\closing|.  It is printed below your signature.  At the
% start of the \LaTeX\ run it's empty.
%    \begin{macrocode}
\newcommand{\fromsig}{} \let\fromsig\@empty
%    \end{macrocode}
% \end{macro}
% If the user has set |\fromsig| in the config file or the preamble, this
% remains untouched.  If not, a possibly set |\@author| is used.  If both are
% empty, well, then you won't get a signature.
%    \begin{macrocode}
\AtBeginDocument{\ifx\@empty\fromsig
  \ifx\@author\@emptyauthor\else\def\fromsig{\@author}\fi\fi}
%    \end{macrocode}
% \begin{macro}{\closinghook}
% This is empty by default.  If you set it to something else, this is printed
% between the closing sentence and the signature.  You may use it e.\,g.\ for a
% signature graphics.
%    \begin{macrocode}
\let\closinghook\@empty
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\closing}
% By and large this code is copied from \mboxtt{letter.cls} and has almost the
% same semantics here.
%    \begin{macrocode}
\newcommand{\closing}[1]{\par\nobreak\vspace{\parskip}%
  \stopbreaks
  \noindent
  \ifx\@empty\fromaddress\else
  \hspace*{\longindentation}\fi
  \parbox{\indentedwidth}{\raggedright
       \ignorespaces #1\ifx\@empty\closinghook
         \\[6\medskipamount]\else\\\relax\closinghook\fi%
       \fromsig\strut}%
   \par}
%    \end{macrocode}
% \end{macro}
%
% \section{Headers and footers}
% \label{Headers}
%
% I use the \mboxtt{fancyhdr} package for customised headers and footers.
%    \begin{macrocode}
\RequirePackage{fancyhdr}
\AtBeginDocument{\pagestyle{fancy}}
%    \end{macrocode}
% I set headers \emph{and} footers to assure that whole pages are transmitted.
% The author, subject and page number are printed at the top.
%    \begin{macrocode}
\fancyhf{}
\fancyhead[LO]{\leavevmode
  \hbox to 0pt{\ifx\@author\@emptyauthor
    \else\expandafter\MakeUppercase\fromname\
    \@author: \fi\emph{\f@xsubjectshort}\hss}}
\fancyhead[RO]{\leavevmode
  \hbox to 0pt{\hss\onepagename\
    \thepage\ \ofname\ \pageref{LastPage}}}
%    \end{macrocode}
% The date and page number are printed at the bottom.
%    \begin{macrocode}
\fancyfoot[LO]{\leavevmode\hbox to 0pt{\@date\hss}}
\fancyfoot[RO]{\leavevmode
  \hbox to 0pt{\hss\onepagename\
    \thepage\ \ofname\ \pageref{LastPage}}}
%    \end{macrocode}
% \begin{macro}{\footrulewidth}
% This is a \mboxtt{fancyhdr} macro that I redefine to a sensible value.
%    \begin{macrocode}
\renewcommand{\footrulewidth}{0.4pt}
%    \end{macrocode}
% The following seems to be necessary for a large font size (i.\,e.,~12pt).
%    \begin{macrocode}
\setlength{\headheight}{15.5pt}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
%</facsimile>
%    \end{macrocode}
%
% \Finale

\endinput

% LocalWords:  ascii dtx paren cls TDS texmf cfg sender's eps dvi german koma
% LocalWords:  KOMA's scrartcl fac latin tex stra DNJ Riboni FixMe jvilhena Lua
% LocalWords:  Ozan Oktem
