From 91246f7e2ca9d473b451e7325f5daeacf55d1f21 Mon Sep 17 00:00:00 2001
From: Eugeniy Mikhailov <evgmik@gmail.com>
Date: Wed, 17 Dec 2014 02:56:24 -0500
Subject: address goes to the right header on the first page

---
 wmletterhead.cls | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

(limited to 'wmletterhead.cls')

diff --git a/wmletterhead.cls b/wmletterhead.cls
index ef23549..ebb66e7 100644
--- a/wmletterhead.cls
+++ b/wmletterhead.cls
@@ -110,6 +110,13 @@
 	\renewcommand{\headrulewidth}{0pt}%
 	\fancyfoot[C]{\thepage}%
 }
+
+\newcommand{\wmaddress}{
+	{\raggedleft\begin{tabular}{l@{}}\ignorespaces
+		\fromaddress \\*[2\parskip]%
+			\@date \end{tabular}}%
+}
+
 \fancypagestyle{firstpage}{% looks like this has no effect for the letter class
 	\wmheader{}%
 }
@@ -118,6 +125,30 @@
 }
 \fancypagestyle{empty}{% 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}
+	\addtolength{\wmaddresshpos}{-\wmrightmargin}
+	\addtolength{\wmaddresshpos}{-\wmaddresswidth}
+	\fancyhead[R]{%
+		\begin{textblock*}{\wmaddresswidth}(\wmaddresshpos{},\wmlogovpos{})%
+			\wmaddress{}%
+		\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]{\ifx\@empty\fromaddress
+  \thispagestyle{firstpage}%
+    {\raggedleft\@date\par}%
+  \else  % home address
+    \thispagestyle{empty}%
+  \fi
+  {\raggedright \toname \\ \toaddress \par}%
+  \vspace{2\parskip}%
+  #1\par\nobreak}
+% -------------------------------------------------------------------
-- 
cgit v1.2.3

