\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{uuletter}
  [2006/03/30 Universiteit Utrecht class for letters version 2.0]
\input{uuletter.cfg}

% Language options. You can add additional languages with similar code.
% Please use the same names as in the babel package.

% Dutch (default)
\def\languagename{dutch} % default language
\DeclareOption{dutch}{\def\languagename{dutch}}

\def\uuletter@dutch{
  \def\enclname{Bijlage(n)}
  \def\ofname{van}
  \def\headtoname{Aan}
  % definieer kopjes
  \def\uuletter@Datum{Datum}
  \def\uuletter@Onderwerp{Onderwerp}
  \def\uuletter@Uwkenmerk{Uw kenmerk}
  \def\uuletter@Onskenmerk{Ons kenmerk}
  \def\uuletter@Faxnummer{Faxnummer}
  \def\uuletter@Telefoon{Telefoon}
  \def\uuletter@Email{E-mail}
  \def\uuletter@Blad{Blad}
  \def\today{\number\day\space\ifcase\month\or
    jan\or feb\or maart\or apr\or mei\or juni\or
    juli\or aug\or sept\or okt\or nov\or dec\fi
    \space\number\year}
}

% English

\DeclareOption{english}{\def\languagename{english}}
\def\uuletter@english{%
 \def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}%
  \def\enclname{encl}%
  \def\headtoname{To}%
  \def\ofname{of}%
  % definieer kopjes
  \def\uuletter@Datum{Date}
  \def\uuletter@Onderwerp{Subject}
  \def\uuletter@Uwkenmerk{Your reference}
  \def\uuletter@Onskenmerk{Our reference}
  \def\uuletter@Faxnummer{Fax number}
  \def\uuletter@Telefoon{Telephone}
  \def\uuletter@Email{E-mail}
  \def\uuletter@Blad{Page}
}

\AtBeginDocument{%
  \@ifpackageloaded{babel}{%
    \addto\extrasdutch{\uuletter@dutch}%
    \addto\extrasenglish{\uuletter@english}%
}{\csname uuletter@\languagename\endcsname}}

% Other options

\DeclareOption{logo}{\def\uu@logo{\includegraphics{UULogoSolRight}}}
\let\uu@logo\relax
\DeclareOption{sigleft}{\def\sig@left{0pt}}
\DeclareOption{sigright}{\def\sig@left{.5\textwidth}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{letter}}
\ProcessOptions
\LoadClass{letter}

\ifx\uu@logo\relax
  \def\uu@logo{\rule{0pt}{18mm}}
\else
  \RequirePackage{graphicx}
\fi
\ifx\pdfpageheight\@undefined
\else
  \pdfpagewidth=21cm
  \pdfpageheight=29.7cm
\fi
\oddsidemargin 0mm
\evensidemargin 0mm
\topmargin -12mm
\headsep 12pt
\headheight 40mm
\textheight 215mm
\textwidth 166mm
\floatsep 12pt plus 2pt minus 2pt
\textfloatsep 20pt plus 2pt minus 4pt
\intextsep 12pt plus 2pt minus 2pt
\dblfloatsep 12pt plus 2pt minus 2pt
\dbltextfloatsep 20pt plus 2pt minus 4pt
\@fptop 0pt plus 1fil
\@fpsep 8pt plus 2fil
\@fpbot 0pt plus 1fil
\@dblfptop 0pt plus 1fil
\@dblfpsep 8pt plus 2fil
\@dblfpbot 0pt plus 1fil

\longindentation=\sig@left
\ifx\undefined\xipt
  \def\xipt{\family{cmss}\size{11}{12pt}\series{m}\shape{n}}
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\raggedright{\@rightskip\z@ plus3em\spaceskip.3333em%
  \xspaceskip.5em%
  \rightskip\@rightskip%
  \leftskip\z@skip%
  \parindent\z@skip\relax}

\def\k@pje#1#2{{\baselineskip=4mm\boldheadfont\selk@pje{#1}\\\fieldfont#2\par}}
\def\selk@pje#1{\noindent
  \expandafter\ifx\csname uuletter@#1\endcsname\relax#1%
  \else \csname uuletter@#1\endcsname
  \fi
}
\def\uuletter@lang#1{%
  \expandafter\ifx\csname#1@\languagename\endcsname\relax
    \csname#1@dutch\endcsname
  \else
    \csname#1@\languagename\endcsname
  \fi
}
\def\threefold{}        % For backward compatibility

\renewcommand{\opening}[1]{%
\thispagestyle{firstpage}
\begingroup
  \parindent=\z@skip\parskip=\z@skip
  \vspace*{-8mm}\vspace{-\headheight}%
  \hspace*{10cm}\makebox[6cm][l]{\uu@logo}\\[3mm]
  \parbox[t]{10cm}{%
    {\boldheadfont\uuletter@lang{adr}\\[6mm]
      \uuletter@lang{postadr}}\\
    \setbox0=\vbox{\parshape=5 \z@ 92mm \z@ 91mm \z@ 90mm \z@ 88mm \z@ 86mm
     \noindent \toname \\ \toaddress
     \rightskip=0pt plus2em\par}%
    \ifdim\ht0>30mm \typeout{*********************************************}%
    \typeout{* Address material does not fit in window!! *}%
    \typeout{*********************************************}\fi
    \vbox to 30mm{\vss\box0\vss}\\[17mm]%
    \k@pje{Datum}{\@date}%
    \k@pje{Onderwerp}{\Subj}
  }%
  \parbox[t]{66mm}{\baselineskip=12pt\rightskip=\@flushglue
    {\uuletter@lang{dept}}\\[22mm]
    \ifx\UwKenmerk\empty
      \k@pje{}{}%
    \else
      \k@pje{Uwkenmerk}{\UwKenmerk}%
    \fi
    \k@pje{Onskenmerk}{\OnsKenmerk}%
    \k@pje{Faxnummer}{\Faxnummer}%
    \k@pje{Telefoon}{\Telefoon}%
    \k@pje{Email}{\Emailaddress}%
    \k@pje{Blad}{\PageNumber}%
  }%
  \par
  \vspace*{6ex plus 100pt}\relax
  #1\par
\endgroup
\regelv@l
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\closing}[1]{\par\nobreak\vspace{\parskip}
\stopbreaks
\noindent
%\ifx\@empty\fromaddress\else
\hspace*{\longindentation}%\fi
\parbox{\indentedwidth}{\raggedright
\ignorespaces #1\\[8\medskipamount]
\ifx\@empty\fromsig
\fromname
\else \fromsig \fi\strut}
\par}

\def\email#1{\def\Emailaddress{#1}}
\def\Emailaddress{}
\def\fax#1{\def\Faxnummer{#1}}
\def\Faxnummer{}
\def\telephone#1{\def\Telefoon{#1}}
\def\Telefoon{}
\def\uwk#1{\def\UwKenmerk{#1}}
\let\youref=\uwk
\def\UwKenmerk{}
\def\onsk#1{\def\OnsKenmerk{#1}}
\let\ourref=\onsk
\def\OnsKenmerk{}
\def\subject#1{\def\Subj{#1}}
\def\Subj{}

\let\@texttop=\relax
\def\ps@headings{\def\@oddhead{\sl \ignorespaces\toname \hfil \@date
\hfil --\ \thepage\ --}\def\@oddfoot{}}
\def\ps@empty{\def\@oddhead{}\def\@oddfoot{}\def\@evenhead{}\def\@evenfoot{}}
\def\ps@firstpage{\def\@oddhead{}\def\@oddfoot{}\def\@evenhead{}\def\@evenfoot{}}
\def\ps@plain{\def\@oddhead{}\def\@oddfoot{\rm\hfil\thepage
 \hfil}\def\@evenhead{}\let\@evenfoot\@oddfoot}
\def\ps@vervolgblad{%
  \def\@oddhead{%
    \parbox[b]{10cm}{%
      {\boldheadfont \selk@pje{Blad}} \PageNumber\\\mbox{}
    }%
    \parbox[b][\headheight][t]{66mm}{%
      \baselineskip=12pt\rightskip=\@flushglue
      \makebox[6cm][l]{\uu@logo}\\[3mm]
      {\uuletter@lang{dept}}\vss
    }}
  \def\@oddfoot{}\let\@evenhead\@oddhead\let\@evenfoot\@oddfoot
}

\parskip .7em \parindent 0pt \topsep .4em \partopsep 0pt \itemsep .4em 
\@lowpenalty 51 \@medpenalty 151 \@highpenalty 301 
\@beginparpenalty -\@lowpenalty \@endparpenalty -\@lowpenalty \@itempenalty
-\@lowpenalty 

\leftmargini 2.5em
\leftmarginii 2.2em \leftmarginiii 1.87em \leftmarginiv 1.7em \leftmarginv 1em
\leftmarginvi 1em
\leftmargin\leftmargini
\labelwidth\leftmargini\advance\labelwidth-\labelsep
\labelsep 5pt
\parsep 0pt
\let\@listi\relax
\def\@listii{\leftmargin\leftmarginii
 \labelwidth\leftmarginii\advance\labelwidth-\labelsep}
\def\@listiii{\leftmargin\leftmarginiii
 \labelwidth\leftmarginiii\advance\labelwidth-\labelsep
 \topsep .2em 
 \itemsep \topsep}
\def\@listiv{\leftmargin\leftmarginiv
 \labelwidth\leftmarginiv\advance\labelwidth-\labelsep}
\def\@listv{\leftmargin\leftmarginv
 \labelwidth\leftmarginv\advance\labelwidth-\labelsep}
\def\@listvi{\leftmargin\leftmarginvi
 \labelwidth\leftmarginvi\advance\labelwidth-\labelsep}

\def\labelenumi{\arabic{enumi}.} 
\def\theenumi{\arabic{enumi}} 
\def\labelenumii{(\alph{enumii})}
\def\theenumii{\alph{enumii}}
\def\p@enumii{\theenumi}
\def\labelenumiii{\roman{enumiii}.}
\def\theenumiii{\roman{enumiii}}
\def\p@enumiii{\theenumi(\theenumii)}
\def\labelenumiv{\Alph{enumiv}.}
\def\theenumiv{\Alph{enumiv}} 
\def\p@enumiv{\p@enumiii\theenumiii}

\def\labelitemi{$\bullet$}
\def\labelitemii{\bf --}
\def\labelitemiii{$\ast$}
\def\labelitemiv{$\cdot$}
\def\verse{\let\\=\@centercr 
 \list{}{\itemsep\z@skip \itemindent -15pt\listparindent \itemindent 
 \rightmargin\leftmargin\advance\leftmargin 15pt}\item[]}
\let\endverse\endlist
\def\quotation{\list{}{\listparindent 1.5em
 \itemindent\listparindent
 \rightmargin\leftmargin}\item[]}
\let\endquotation=\endlist
\def\quote{\list{}{\rightmargin\leftmargin}\item[]}
\let\endquote=\endlist

\def\descriptionlabel#1{\hfil \it #1}
\def\description{\list{}{\leftmargin\descriptionmargin
 \labelwidth\leftmargin \advance\labelwidth -\labelsep 
 \let\makelabel\descriptionlabel}}
\let\enddescription\endlist
\newdimen\descriptionmargin
\descriptionmargin=3em

\def\theequation{\arabic{equation}}

\arraycolsep 5pt \tabcolsep 6pt \arrayrulewidth .4pt \doublerulesep 2pt 
\tabbingsep \labelsep 
\skip\@mpfootins = \skip\footins
\fboxsep = 3pt \fboxrule = .4pt 

\def\footnoterule{\kern-1\p@ 
 \hrule width .4\columnwidth 
 \kern .6\p@} 

\long\def\@makefntext#1{\noindent \hangindent 5pt\hbox 
 to 5pt{\hss $^{\@thefnmark}$}#1}

\c@topnumber=2
\def\topfraction{.7}
\c@bottomnumber=1
\def\bottomfraction{.3}
\c@totalnumber=3
\def\textfraction{.2}
\def\floatpagefraction{.5}
\c@dbltopnumber= 2
\def\dbltopfraction{.7}
\def\dblfloatpagefraction{.5}

%\def\today{\ifcase\month\or
% January\or February\or March\or April\or May\or June\or
% July\or August\or September\or October\or November\or December\fi
% \space\number\day, \number\year}

\smallskipamount=.5\parskip \medskipamount=\parskip
\bigskipamount=2\parskip
\pagenumbering{arabic} \onecolumn %\@fileswfalse 
\pagestyle{vervolgblad}
\csname uuletterinit\endcsname
