[Tex/LaTex] the right way to place a box at a specific location

letterheadpositioning

I have a box \mybox that contains a letterhead. The dimensions of the box are 7" by 1" (and depth 0pt). The box is going to be used only inside my letterhead macro:

\DeclareRobustCommand\letterhead{%
        \cleardoublepage % letterhead only belongs at the top of a page
        % something
        \copy\mybox
        % something
}

Thus, the letterhead can only appear at the top of the page.

My requirements are that \mybox needs to be .75" from the left and right margin, .5" from the top margin and at least .5" from the text of the page on which the letterhead appears. Further, (since I cannot convince people to upgrade their TeX distributions) it needs to work with a fairly old version of teTeX. The teTeX requirement rules out wallpaper and textpos. The requirement that the text of the page be at least some distance would also rule those out in addition to eso-pic. Thus, my situation is different from this one.

Right now, I'm forcing the margins to be 1" via \RequirePackage[margin=1in]{geometry}, but I'd like not to have to do that. I'd prefer that any margins could be set and the letterhead stay in exactly the same place and that the minimum of .5" between the letterhead and the text of the page be maintained. (Actually, a way to set that via a package option would be handy and it'd encourage me to learn how to use xkeyval. For a default, .5" seems pretty good, and it falls out nicely from my current solution.)

Since the margin is currently forced to be 1", my solution is the following.

\newbox\mybox
\setbox\mybox\vbox to1in{
        \vss
        % TeX to generate the letterhead
        \vskip.5in
}

\DeclareRobustCommand\letterhead{%
        \cleardoublepage
        \hb@xt@\z@{%
                \skip\z@\oddsidemargin
                \advance\skip\z@.25in
                \hskip-\skip\z@
                \copy\mybox
                \hss
        }
}

(Using \moveleft also works nicely. I'm not sure which way is better.)

I should be able to remove the \vss and \vskip.5in from \mybox and position the box appropriately. What is the correct way to do this?

Best Answer

Update: Here's an example that's actually working. Just had my calculations a bit off, earlier. This isn't exactly reproducing your example output, but this should be flexible enough that you can insert whatever you like.

\documentclass{article}
\usepackage{lipsum}
\usepackage[a4paper,margin=2in]{geometry}

\newbox\mybox

\newcommand\letterhead{%
  \cleardoublepage
  \setbox\mybox=\vbox{%
    \parindent=0pt
    \vskip\dimexpr-1in-\voffset-\topmargin-\headheight-\headsep-\topskip\relax
    \hbox to \paperwidth{\letterheadcontents\hss}%
  }
  \dp\mybox=0pt\ht\mybox=0pt\wd\mybox=0pt        
  \moveleft\dimexpr1in+\hoffset+\oddsidemargin\relax
  \box\mybox
  \vskip-\baselineskip
}

\def\letterheadcontents{%
  \hspace*{\fill}%
  \fbox{\parbox{7in}{hello\\ this is my letterhead}}%
  \hspace*{\fill}%
}

\begin{document}
\letterhead
\lipsum
\end{document}