Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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}
share|improve this answer
    
This is so frustrating. Try adding the class option 12pt. The box moves slightly! –  TH. Sep 12 '10 at 7:22
    
Try this one, instead :) –  Will Robertson Sep 12 '10 at 8:14
    
\topskip! That's what the problem was. I'll update my answer (and mark it community wiki which is what I meant to do when I first posted it; it seems silly to get rep for a question and an answer). –  TH. Sep 12 '10 at 9:36

This seems to work. Credit to Will for pointing out what was missing!

\documentclass[10pt]{article}
\usepackage{lipsum}
\usepackage[margin=1in]{geometry}
\makeatletter
\newbox\mybox
\setbox\mybox\vbox{
        \hrule \@height.5in \@depth.5in \@width7in
}
\wd\mybox\z@

\DeclareRobustCommand\letterhead{%
        \cleardoublepage
        \begingroup
                \skip\z@\topmargin
                \advance\skip\z@\headheight
                \advance\skip\z@\headsep
                \advance\skip\z@\topskip
                \advance\skip\z@\voffset
                \advance\skip\z@-.5in
                \setbox\z@\vbox to\z@{
                        \vss
                        \skip\tw@\oddsidemargin
                        \skip\tw@\hoffset
                        \advance\skip\tw@.25in
                        \moveleft\skip\tw@\copy\mybox
                        \vskip\skip\z@
                }
                \advance\skip\z@-.5in
                \dp\z@-\skip\z@
                \box\z@
                \nointerlineskip
        \endgroup
}
\makeatother
\begin{document}
\letterhead
\lipsum
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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