1. Panagiotis Mavrogiorgos
  2. cover-letter

Source

cover-letter / cover-letter.sty

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cover-letter}[2011/6/18 v1.0 Package `cover-letter.sty']
\typeout{Package `cover-letter' version 1.0 by Panagiotis Mavrogiorgos}

% cover-letter is a package for typesetting letters.
% A key - value model is used for the input through pgfopts package
% The symbols are provided by the marvosym package

\RequirePackage{pgfopts}
\RequirePackage{xspace}
\RequirePackage{etoolbox}
\RequirePackage{marvosym}
\RequirePackage{paralist}
\RequirePackage{hyperref}
\RequirePackage{url}
\RequirePackage{fancyhdr}
\RequirePackage{totcount}

% Page numbering
\regtotcounter{page}
\pagestyle{empty}

\newcommand{\showpagenumbers}{%
    \newcounter{totalpages}
    \setcounter{totalpages}{\totvalue{page}}
    \pagestyle{fancy}
    \fancyhead[RCL]{}
    \fancyfoot[RL]{}
    \fancyfoot[C]{\emph{Page \textbf{\thepage}\ of \textbf{\thetotalpages}}}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}


% Key definition
\pgfqkeys{/recipient}{
    Firstname/.store in = \recipFirstname,
    Lastname/.store in = \recipLastname,
    AddressA/.store in = \recipAddressA,
    AddressB/.store in = \recipAddressB,
    AddressC/.store in = \recipAddressC,
}

\pgfqkeys{/sender}{
    Firstname/.store in = \senderFirstname,
    Lastname/.store in = \senderLastname,
    Title/.store in = \senderTitle,
    AddressA/.store in = \senderAddressA,
    AddressB/.store in = \senderAddressB,
    AddressC/.store in = \senderAddressC,
    Email/.store in = \senderEmail,
    Mobile/.store in = \senderMobile,
    Phone/.store in = \senderPhone,
    Fax/.store in = \senderFax,
    Homepage/.store in = \senderHomepage,
}

\pgfqkeys{/enclosures}{
    name/.store in = \enclosureName,
    itemA/.store in = \enclosureA,
    itemB/.store in = \enclosureB,
    itemC/.store in = \enclosureC,
    itemD/.store in = \enclosureD,
    itemE/.store in = \enclosureE,
}

\ProcessPgfOptions{/sender}
\ProcessPgfOptions{/recipient}
\ProcessPgfOptions{/enclosures}


\newcommand{\typesetSender}{
    \hfill%
    \begin{minipage}[t]{\textwidth}
        \raggedleft
        \textbf{\senderFirstname \xspace \senderLastname}\\[.35ex]
        {\small\itshape%
            \hfill
            % address lines
            \ifdefvoid{\senderAddressA}{}{\hfill \senderAddressA \\}
            \ifdefvoid{\senderAddressB}{}{\hfill \senderAddressB \\}
            \ifdefvoid{\senderAddressC}{}{\hfill \senderAddressC \\}
            % rest
            \ifdefvoid{\senderMobile}{}{\Mobilefone~\senderMobile \\}
            \ifdefvoid{\senderPhone}{}{\Telefon~\senderPhone \\}
            \ifdefvoid{\senderFax}{}{\Fax~\senderFax \\}
            \ifdefvoid{\senderEmail}{}{\Letter~\href{mailto:\senderEmail}{\senderEmail} \\}
            %\ifdefvoid{\senderHomepage}{}{\Homepage~\url{\senderHomepage} \\}
        }
    \end{minipage}
}

\newcommand{\typesetRecipient}{
    \begin{minipage}[t]{.4\textwidth}
        \raggedright%
        \textbf{\recipFirstname \xspace \recipLastname}\\[.35ex]
        {\small\itshape%
            % address line
            \ifdefvoid{\recipAddressA}{}{\recipAddressA \hfill \\}
            \ifdefvoid{\recipAddressB}{}{\recipAddressB \hfill \\}
            \ifdefvoid{\recipAddressC}{}{\recipAddressC \hfill \\}
        }
    \end{minipage}
}

\newcommand{\typesetDate}{
    \begin{minipage}[t]{\textwidth}
        \raggedleft \hfill \today
        \newline
    \end{minipage}
}

\newcommand{\senderFullname}{\senderFirstname \xspace \senderLastname}

\newcommand{\typesetSignature}{%
    \textbf{\senderFullname}
    \ifdefvoid{\senderTitle}{}{{\newline \small \itshape \senderTitle}}
}


\newcommand{\typesetEnclosures}{
    \vfill
    \textit{
        \ifdefvoid{\enclosureA}{}{%
            \textbf{\enclosureName}:
            \begin{compactitem}
                \item \enclosureA
                \ifdefvoid{\enclosureB}{}{\item \enclosureB}
                \ifdefvoid{\enclosureC}{}{\item \enclosureC}
                \ifdefvoid{\enclosureD}{}{\item \enclosureD}
                \ifdefvoid{\enclosureE}{}{\item \enclosureE}
            \end{compactitem}
        }
    }
}