1

I'm trying to mimic a letterhead with a continuation page. The letterhead format is as follows: a colour banner on the first page, with a logo positioned on the right and a department name on the left. Also on the first page is the department address near the bottom. All of these must be positioned absolutely. The continuation page has the logo, at the same position, but nothing else.

In my ignorance, I thought I would do the absolute positioning with tikz, using page coordinates. This works for the first page, but does not seem to work for any continuation page. That is, the continuation pages should include the logo, and only the logo, but they don't include anything. So far I haven't been able to find any answer that quite addresses the question, and I'm quite sure I'm lost in silly mistakes in fancyhdr, and probably doing it the wrong way to boot.

Here's an example of the current output. The second page and all subsequent pages should have a demo image at exactly the same position as the first page.

image of output to show the problem

Here's the class file

% class file MWE
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mweletter}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{letter}}

\ProcessOptions

\RequirePackage[demo]{graphicx}
\LoadClass[a4paper]{letter}
\RequirePackage[left=2.5cm,showframe]{geometry}
\RequirePackage{fancyhdr}
\RequirePackage{tikz}
%\RequirePackage{fontspec}
\usetikzlibrary{calc}

\newsavebox{\addressbox}
\savebox{\addressbox}{
  \sffamily\fontsize{8}{10}\selectfont
  \textcolor{blue}{\begin{minipage}{7cm}
      Block A Level 4, Simpson Street, Springfield USA  \\%
    Tel: (+1) 617 123 4567 \\
  \end{minipage}}
}

\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0pt}%

\pagestyle{plain}
\AtBeginDocument{\thispagestyle{firstpage}}

\fancypagestyle{firstpage}{%
  \fancyhf{}%
  \begin{tikzpicture}[overlay, remember picture]
    \fill [anchor=north west,inner sep=0pt,orange]
      (current page.north west)  rectangle ($(current page.north east) + (0,-3cm)$);
    \node[anchor=north east,inner sep=0pt] at ($(current page.north east) + (-1cm,-0.5cm)$)
      {\includegraphics[height = 1.6cm]{demo}};
    \node[anchor=north west,inner sep=0pt] at
     ($(current page.north west) + (2.5cm,-0.5cm)$) {
      \sffamily\fontsize{8}{12} Department
      of Excellent Science };
    \node[anchor=south west, inner sep=0pt] at
    ($(current page.south west) + (2.5cm,1.5cm)$) {\usebox{\addressbox}};
  \end{tikzpicture}
}

\fancypagestyle{plain}{%
  \fancyhf{}%
  \begin{tikzpicture}[overlay, remember picture]
    \node[anchor=north east,inner sep=0pt]
    at ($(current page.north east) + (-1cm,-0.5cm)$)
    {\includegraphics[height = 1.6cm]{demo}};
  \end{tikzpicture}
}

And a latex file to run through it.

\documentclass[12pt]{mweletter}
\usepackage{blindtext}
\signature{%
  Johnathan "John" I.Q. Neidelbaum Frink, Jr., B.Sc., Ph.D. M.R.S.C. \\ 
  The Principal Professor \\
  Springfield Heights Institute of Technology \\
  Springfield, America
}
\date{\today}
\begin{document}
\begin{letter}{Prof Tan\\
    Beijing Da Xue}
\opening{Dear Prof Tan,}
\Blindtext[5]
\closing{Yours sincerely,}
\encl{mweletter.cls}
\ps{Please see the enclosed file.}
\cc{Lisa Simpson}
\end{letter}
\end{document}
  • 1
    I don't know what all these macros do. However if you just want to always have the picture at this position, you may use eso-pic. That way you will not depend on the mercy of \fancypagestyle{plain}{. – marmot Feb 11 '18 at 4:23
  • 1
    All your headers and footers are empty. – cfr Feb 11 '18 at 4:52
  • @marmot, now I realise how pointless it was to use fancyhdr, and have a working solution that uses eso-pic, which I wasn't aware of. Not sure whether to delete the question, or whether the answer might be helpful for others. – GTK Feb 11 '18 at 5:02
  • @CarLaTeX, OK, done. – GTK Feb 11 '18 at 10:02
2

marmot's comment made me realise how silly it was to use fancyhdr in the first place. I was completely unaware of eso-pic. This simply places the elements on the pages, and treats the first page differently.

% mweletter.cls
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mweletter}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{letter}}
\ProcessOptions
\RequirePackage[demo]{graphicx}
\LoadClass[a4paper]{letter}
\RequirePackage[left=2.5cm,showframe]{geometry}
\RequirePackage{tikz}
\RequirePackage{eso-pic}
\usetikzlibrary{calc}

\AddToShipoutPicture{
  \begin{tikzpicture}[overlay, remember picture]
    \ifnum\value{page}=1 
    \fill [anchor=north west,inner sep=0pt,orange]
    (current page.north west)  rectangle ($(current page.north east) + (0,-3cm)$);
    \node[anchor=north west,inner sep=0pt] at
     ($(current page.north west) + (2.5cm,-0.5cm)$) {
      \sffamily\fontsize{8}{12} Department
      of Excellent Science };
    \node[anchor=south west, inner sep=0pt] at
    ($(current page.south west) + (2.5cm,1.5cm)$) {
      \sffamily\fontsize{8}{10}\selectfont
      \textcolor{blue}{
        \begin{minipage}{7cm}
          Block A Level 4, Simpson Street, Springfield USA  \\%
          Tel: (+1) 617 123 4567 \\
        \end{minipage}}};
    \fi
    \node[anchor=north east,inner sep=0pt] at ($(current page.north east) + (-1cm,-0.5cm)$)
    {\includegraphics[height = 1.6cm]{demo}};
  \end{tikzpicture}
}

And here's the input

\documentclass[12pt]{mweletter}
\usepackage{blindtext}
\signature{%
  Johnathan "John" I.Q. Neidelbaum Frink, Jr., B.Sc., Ph.D. M.R.S.C. \\ 
  The Principal Professor \\
  Springfield Heights Institute of Technology \\
  Springfield, America
}
\date{\today}
\begin{document}
\begin{letter}{Prof Tan\\
    Beijing Da Xue}
\opening{Dear Prof Tan,}
\Blindtext[4]
\closing{Yours sincerely,}
\encl{mweletter.cls}
\ps{Please see the enclosed file.}
\cc{Lisa Simpson}
\end{letter}
\end{document}

To give

correct 2up

  • OK, upvoted! In a couple of days you can accept your own answer. – CarLaTeX Feb 11 '18 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.