2

I'm attempting to create text for an envelope. The sender is in the top-left corner, and the recipient should be centred vertically and horizontally with respect to the edges of the paper. That is, the presence of the sender should not change the vertical alignment of the recipient.

\documentclass{letter}
\usepackage[papersize={110mm,220mm},landscape,margin=5mm,twoside=false]{geometry}
\setlength\parskip{0pt}
\pagestyle{empty}

\begin{document}

If undeliverable, please return to:

Joe Citizen

12345 Foo St

Bar BAZ 67890

\huge
RECIPIENT LINE 1

RECIPIENT LINE 2

RECIPIENT LINE 3

\end{document}

How can I vertically centre the RECIPIENT lines with respect to the entire page? The block itself should be centred, but text within it should be left justified.

1

2 Answers 2

4

Use center and \vspace*{\fill}; for the addressee, it's better to use tabular, so to get left alignment in the respective rows. For the return address, use a zero height box.

\documentclass{letter}
\usepackage[
  papersize={110mm,220mm},
  landscape,
  margin=5mm,
  twoside=false
]{geometry}

\setlength\parskip{0pt}
\setlength\parindent{0pt}
\setlength\topskip{0pt}

\pagestyle{empty}

\begin{document}

\parbox[t][0pt]{\textwidth}{
  \vspace{0pt}% to set the reference point
  \raggedright
  If undeliverable, please return to:\\
  Joe Citizen\\
  12345 Foo St\\
  Bar BAZ 67890
}

\vspace*{\fill}

\begin{center}
\huge
\begin{tabular}{@{}l@{}}
Joe Citizen\\
12345 Foo St\\
Bar BAZ 67890
\end{tabular}
\end{center}

\vspace*{\fill}

\end{document}

enter image description here

7
  • This mostly works, but \vspace{0pt} creates an additional margin at the top, so all the text is shifted down.
    – Sparhawk
    Commented Aug 31, 2017 at 11:43
  • @Sparhawk Use \vspace{-\ht\strutbox}
    – egreg
    Commented Aug 31, 2017 at 19:32
  • This removes the top margin, but the text is still not vertically centred. I measure the gap above the recipient block to be ~9% larger than the gap below. In comparison, the tikz solution is much more precise.
    – Sparhawk
    Commented Sep 1, 2017 at 2:04
  • @Sparhawk You probably want to set \topskip to zero
    – egreg
    Commented Sep 1, 2017 at 8:42
  • That also shifts the sender up. It's most evident if I set margin=0mm, then the sender runs off the top of the page.
    – Sparhawk
    Commented Sep 4, 2017 at 3:07
3

I would use tikz for that:

\documentclass{letter}
\usepackage[papersize={110mm,220mm},landscape,margin=5mm,twoside=false]{geometry}
\setlength\parskip{0pt}
\pagestyle{empty}

\usepackage{tikz}


\begin{document}

If undeliverable, please return to:

Joe Citizen

12345 Foo St

Bar BAZ 67890
\begin{tikzpicture}[remember picture,overlay]
    \node at (current page.center)
        {\huge\begin{tabular}{@{}l@{}}
            RECIPIENT LINE 1\\
            RECIPIENT LINE 21\\
            RECIPIENT LINE 3
        \end{tabular}};
\end{tikzpicture}

\end{document}

enter image description here

4
  • This works, but I find I have to pdflatex twice. Is that just something to do with tikz?
    – Sparhawk
    Commented Aug 31, 2017 at 11:44
  • 1
    @Sparhawk yes, this is because tikz's positioning option current page.center might need two runs to determine the needed shift to actually hit the center.
    – Skillmon
    Commented Aug 31, 2017 at 11:52
  • Pretty close, but the top gap is 4% shorter than the bottom gap, when I set margin=0mm. Probably good enough, but I wonder why the slight discrepancy.
    – Sparhawk
    Commented Sep 3, 2017 at 21:41
  • @Sparhawk honestly I have no clue. Perhaps because those are all uppercase letters. Try with an \fbox around the tabular with \fboxsep=-\fboxrule before the \fbox. This way you could check for the discrepancy correctly.
    – Skillmon
    Commented Sep 3, 2017 at 21:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .