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 am creating an letter options (lco) file that I will use for multiple letters. The scrlttr2 class is designed for a fixed placement of the address field, and places the date at a fixed position from the top of the page (refvpos). I would like to change this so that refvpos is automatically adjusted based on the height of the address. This example results in the date and opening of the letter colliding with the address:

\documentclass[paper=letter]{scrlttr2}
\usepackage[american]{babel}
\areaset{6.5in}{9in}

\KOMAoptions{parskip=full,refline=dateleft,fromalign=right}

\makeatletter
\@setplength{toaddrvpos}{0.5in}
\@setplength{refvpos}{1.5in}
\makeatother

\date{16 February 2012}

\begin{document}
\begin{letter}{Dr.~Leo Lion\\Fordstan University\\Room 50\\1600 Pennsylvania Ave\\Somewhere\\United States of America}
\opening{Dear Sir,}
This is a test.
\closing{Sincerely yours}
\end{letter}
\end{document}

Can I fix this so that the date will always be one \baselineskip after the address, regardless of whether the address is two lines or ten?

share|improve this question
    
You would have to calculate the height before starting the letter. And the height of the address field is preset, too. –  ejoerns Feb 17 '12 at 1:52
    
I wouldn't mind doing something like \newcommand{\address}{Dr.~Leo Lion...}... \begin{letter}{\address}. If I do that, is there a way to calculate the height of address? –  Michael Hoffman Feb 17 '12 at 2:17
add comment

1 Answer

up vote 1 down vote accepted

You could redefine the letter command like this:

\let\oldletter\letter
\renewcommand\letter[1]{%
  \newdimen\height%
  \setbox0=\vbox{#1}%
  \height=\ht0 \advance\height by \dp0%
  \@setplength{toaddrheight}{\height}%
  \@setplength{refvpos}{\useplength{toaddrvpos}}%
  \@addtoplength{refvpos}{\useplength{toaddrheight}}%
  \@addtoplength{refvpos}{2\baselineskip}%
  \oldletter{#1}%
}

It places the address in a vbox, calculates its height, sets the height of the address field and finally calculates the resulting refvpos as a sum of toaddrvpos+toaddrheight+2baselineskip.

Hope it helps.

share|improve this answer
add comment

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.