# Aligning address with body of letter in scrlttr2

In scrlttr2, I wish to align the address with the body of the letter. I tried this:

\@setplength{toaddrhpos}{\oddsidemargin}


But it moves the address almost to the left edge of the paper.

How can I achieve the alignment that I desire?

Example:

### h.lco

\ProvidesFile{h.lco}[2012/07/25]

\endinput


### letter.tex

\documentclass[h]{scrlttr2}

\usepackage[english]{babel}

\begin{document}

Hello.

\closing{Very truly yours,}

\end{letter}
\end{document}

-

Markus Kohm, the author if KOMAscript, has included a nowindow-lco in the samples to his book (see Beispiele aus der 4. Auflage des KOMA-Script-Buches). The sources for the file is:

% nowindow.lco
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status maintained'.
%
% The Current Maintainer of this work is Markus Kohm.
%
% This work consists of this file only.
%-----------------------------------------------------------------------
\ProvidesFile{nowindow.lco}%
[2003/01/24 v0.1 unsupported letter-class-option]
\endinput


Copy this source to a text editor and save it as nowindow.lco in your tex search path (your texmf-local), or to the same directory as your letter. Remember to update the tex file database (run texhash or whatever command on your system, for example ‘Refresh FNDB’ from the Settings in MiKTeX.)

A MWE for the use of nowindow.lco:

\documentclass[UKenglish]{scrlttr2}
\usepackage{babel}
\usepackage[utf8]{inputenx}

\begin{document}
\begin{letter}{Name of Recipient \\ Address \\ of \\ Recipient}

\opening{Hello}  % eg. Hello

\closing{Kind regards} %eg. Regards

\end{letter}
\end{document}


EDIT: PSH asks why you have to add 1in to the \toaddrhpos. This is explained by Markus Kohn in this reply at Komascript’s home page. An approximate translation from German:

In the end the 1in originate from the history of TeX. TeX does not start in the outer margin of the page, but move one inch to the left and one inch down. Consequently, the \oddsidemargin is one inch less than the margin on the even side pages. To make it easier for the user, the pseudo-lenght is calculated from the real left margin (and from the real top of the page). Therefore, you have to take that one inch into consideration when you are using \oddsidemargin in an pseudo-lenght.

(German natives, feel free to improve the translation.)

-
Thank you, but I do not understand why it should be necessary to add 1in. –  PSH Jul 25 '12 at 22:18
This is because TeX by design start the left margin one inch (25.4 mm) from the outer margin and one inch (25.4 mm) from the top margin. You have to compensate for that. You will find the explanation at www.komascript.de if you read German. –  Sveinung Jul 26 '12 at 6:39
Thank you again. Yes, I do read German. I'll have a look at Kohn's explanation. –  PSH Jul 26 '12 at 13:20

At \opening, scrlttr2 "moves into position" to print the "to address" using \move@topl which is defined as:

\newcommand*{\move@topl}{%
\null\hskip -1in%
\ifodd\value{page}\hskip -\oddsidemargin\else\hskip -\evensidemargin\fi
\ignorespaces%
}


followed by an \hskip of size "\toaddrhpos". So, setting "\toaddrhpos" to be the same as the distance skipped by \move@topl (in the opposite direction), voids any horizontal movement. As such, adding

\makeatletter

@PSH: The 1in length is hard-coded in the actual document class file scrlttr2.cls`. That was the author's choice, so there's no way around it. –  Werner Jul 26 '12 at 6:39