diff options
-rw-r--r-- | wmletterhead.cls | 67 |
1 files changed, 56 insertions, 11 deletions
diff --git a/wmletterhead.cls b/wmletterhead.cls index 0d3b28d..b698aa7 100644 --- a/wmletterhead.cls +++ b/wmletterhead.cls @@ -59,6 +59,13 @@ \LoadClass{letter} \RequirePackage{calc} +\RequirePackage{everypage} % allows to redefine geometry depending on a page +\RequirePackage{graphicx} +\RequirePackage{geometry} % easy page layout manipulation +\RequirePackage{adjustbox} +\RequirePackage[absolute]{textpos} % allows to place text in precise position +\RequirePackage{fancyhdr} % Headers ! + % -------------------------------------------------- @@ -67,12 +74,14 @@ \newlength{\wmlogowidth} \newlength{\wmlogohpos} \newlength{\wmlogovpos} +\newlength{\wmlogoWhpos} % distance from the left logo edge to the 'W' in William % below are measured in the Word template \setlength{\wmlogoheight}{0.65in} \setlength{\wmlogowidth}{3.64in}% ideally should be scaled from \wmlogoheight \setlength{\wmlogohpos}{0.76in}% ideally should be calculated from \wmleftmargin and \wmlogoheight \setlength{\wmlogovpos}{0.75in}% same as above +\setlength{\wmlogoWhpos}{0.82in}% same as above % -------------------------------------------------- % Required by WM @@ -87,27 +96,43 @@ \newlength{\wmbottommargin} \setlength{\wmbottommargin}{1.0in} % guessed + +\newlength{\wmtopmargin} %start position for address or logo +\setlength{\wmtopmargin}{1.0in} + + +\newlength{\wmaddressheight} % to be calculated at the opening % -------------------------------------------------- % -------------------------------------------------- % Let's calculate top margin -\newlength{\wmtopmargin} -\setlength{\wmtopmargin}{\wmlogoheight+\wmlogovpos+\wmlogoseparation}% +%\newlength{\wmtopmargin} +%\setlength{\wmtopmargin}{\wmlogoheight+\wmlogovpos+\wmlogoseparation}% % -------------------------------------------------- -\RequirePackage{graphicx} -\RequirePackage[top=\wmtopmargin, left=\wmleftmargin, right=\wmrightmargin, bottom=\wmbottommargin, letterpaper, showframe]{geometry} -\RequirePackage[absolute]{textpos} -\RequirePackage{fancyhdr} +\geometry{ + letterpaper, + top=\wmtopmargin, + left=\wmleftmargin, + right=\wmrightmargin, + bottom=\wmbottommargin, + marginparwidth=0in, + marginparsep=0in, + %showframe % this shows layout frames +} + %% WM fancy letter head definition \newcommand{\wmheader}{ \fancyhf{}% \fancyhead[L]{% - \begin{textblock*}{\wmlogowidth}(\wmlogohpos{},\wmlogovpos{})% +% \begin{textblock*}{\wmlogowidth}(\wmlogohpos{},\wmlogovpos{})% +%\adjustbox{valign=t}{ + \hskip -\wmlogoWhpos \includegraphics[height=\wmlogoheight{},keepaspectratio=true]{\wmheaderlogo}% - \end{textblock*}% +%} +% \end{textblock*}% }% \renewcommand{\headrulewidth}{0pt}% \fancyfoot[C]{\thepage}% @@ -127,31 +152,51 @@ \fancypagestyle{empty}{% looks like this has no effect for the letter class \wmheader{}% } + \fancypagestyle{plain}{% this takes care of the 2nd and the following pages %\wmheader{}% \fancyfoot[C]{\thepage}% } + + \fancypagestyle{firstpage}{% some how this is the very first page style \wmheader{}% - \settoheight{\headheight}{\hbox{\wmaddress}}% \newlength{\wmaddresswidth} \settowidth{\wmaddresswidth}{\hbox{\wmaddress}}% \newlength{\wmaddresshpos} \setlength{\wmaddresshpos}{\paperwidth-\wmrightmargin-\wmaddresswidth} \fancyhead[R]{% - \begin{textblock*}{\wmaddresswidth}(\wmaddresshpos{},\wmlogovpos{})% + %\begin{textblock*}{\wmaddresswidth}(\wmaddresshpos{},\wmlogovpos{})% \wmaddress{}% - \end{textblock*}% + %\end{textblock*}% }% } \pagestyle{plain}% important! if switched to fancy pages 2, 3, ... do not have logo + % ------------------------------------------------------------------- % Now let redefine opening so address goes to the right of logo \renewcommand*{\opening}[1]{ + \settototalheight{\wmaddressheight}{\hbox{\wmaddress}}% + % redefine margins to include headers for the first page only + \AddThispageHook{ + \newgeometry{ + top=\wmtopmargin, + left=\wmleftmargin, + right=\wmrightmargin, + bottom=\wmbottommargin, + marginparwidth=0in, + marginparsep=0in, + includehead, + headsep=\wmlogoseparation, + headheight=\wmaddressheight + } + } \thispagestyle{firstpage}% {\raggedleft\@date\par}% {\raggedright \toname \\ \toaddress \par}% %\vspace{2\parskip}% #1\par\nobreak} % ------------------------------------------------------------------- + +% vim: tabstop=2 shiftwidth=2 expandtab |