我希望变量的文本location
与主体文本右对齐。因此我尝试将长度重新定义lochpos
为与相同refhpos
,因为左侧边距与右侧边距相同,但不起作用。知道我哪里犯了错误吗?
可以找到伪长度此处,第 354 页
梅威瑟:
\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}
答案1
正确的长度似乎是\oddsidemargin+1in
。
所以你应该添加
\makeatletter
\@setplength{lochpos}{\oddsidemargin}
\@addtoplength{lochpos}{1in}
\makeatother
MWE(添加geometry
以显示框架)
\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}
输出: