4

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}
  • Do i remember correctly, that you have to define the pseudolengths in an external file and load them (for example as a global option?). – Johannes_B Jan 5 '15 at 14:36
  • @Johannes_B Yes, when I understand it correctly the pseudolengths are for developers and can be defined in .lco files. But I think the \makeatletter \makeatother should also work. A quick test revealed that it makes no difference if I define it in a .lco file or in the main file. – user2653422 Jan 5 '15 at 14:39
  • Up to using geometry? Since the textwidth is dependant of the DIV-Value, the h-offset needs to be calculated summing up marginparwidth, marginparcolsep ... – Johannes_B Jan 5 '15 at 14:57
  • @Johannes_B Wouldn't it be enoght to subtract from paperwidth the textwidth and the left margin width to get the width of the right margin which should be the correct value for lochpos? But that seems not to work either. I've seen the Komaold letteroption which aligns the text of the location variable correct, but it's an old style which also makes many changes I don't want to have. Could you maybe extend your answer as I don't know how to start now. – user2653422 Jan 5 '15 at 15:18
  • 1
    Aha, well, may I ask which papersize you have choosen for your tex distribution (letter or DIN A4). For me it is A4 (used in Germany). Add \usepackage{showframe} to display the used frame ... Then you can see the needed number. May I ask why you want to do this? – Mensch Jan 5 '15 at 16:49
7

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

  • Thank you, I would never had found the information in the documentation on page 331. – user2653422 Jan 5 '15 at 17:18
  • @user2653422 You're welcome. – karlkoeller Jan 5 '15 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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