[Tex/LaTex] scrlttr2 location positioning question

lengthslettersscrlttr2

I would like to have the text of the variable location to be right aligned with the text of the main body. So I tried to redefine the length lochpos to be the same as refhpos, because the margin on the left is the same as on the right, but it doesn't work.
Any idea where I make a mistake?

The pseudo lengths could be found here, p. 354

MWE:

    \documentclass[foldmarks=true,foldmarks=blmtP,
    version=last]{scrlttr2}
    \usepackage[ngerman]{babel}
    \usepackage{graphics}
    \usepackage{lipsum}

    \makeatletter
    \@setplength{lochpos}{\useplength{refhpos}} 
    \makeatother

    \begin{document}
    \setkomavar{location}{\raggedleft
    Text should be right aligned to the main body text!}
    \begin{letter}{%
    Joana Public\\
    Hillside 1\\
    12345 Public-City%
    }
    \opening{Dear ...,}
    \lipsum[1-2]
    \closing{Regards}

    \end{letter}
    \end{document}

Best Answer

The right lenght seems to be \oddsidemargin+1in.

So you should add

\makeatletter
  \@setplength{lochpos}{\oddsidemargin}
  \@addtoplength{lochpos}{1in}
\makeatother

MWE (added geometry to show the frame)

\documentclass[foldmarks=true,foldmarks=blmtP,
version=last]{scrlttr2}

\usepackage[showframe]{geometry} % just to show the frame

\usepackage[ngerman]{babel}
\usepackage{graphics}
\usepackage{lipsum}

\makeatletter
  \@setplength{lochpos}{\oddsidemargin}
  \@addtoplength{lochpos}{1in}
\makeatother

\begin{document}
\setkomavar{location}{\raggedleft
Text should be right aligned to the main body text!}
\begin{letter}{%
Joana Public\\
Hillside 1\\
12345 Public-City%
}
\opening{Dear ...,}
\lipsum[1-2]
\closing{Regards}

\end{letter}
\end{document} 

Output:

enter image description here

Related Question