[Tex/LaTex] How to position the reference fields line in scrlttr2

koma-scriptletters

TeX newbie. I want to position the reference fields line in scrlttr2 to where the "supplemental data" is usually displayed (in the top right hand corner, below the header).

I figured it would be as easy as

\makeatletter
\@setplength{refvpos}{\useplength{locvpos}}
\@setplength{refhpos}{\useplength{lochpos}}
\@setplength{refwidth}{\useplength{locwidth}}
\makeatother

but that doesn't work, the reference field line is rendered right at the top of the document. Any help would be greatly appreciated! I'm working on an invoice template.

Best Answer

  • Vertical position: Obviously locvpos has a value of 0 pt with your style, which is common for many letter styles. You could set it yourself or use toaddrvpos instead.

  • Horizontal position: refhpos means a distance from the left paper edge, but lochpos from the right paper edge. So you would have to calculate, substracting lochpos and locwidth from \paperwidth to get your new refwidth.

  • Width: You can simply use locwidth as you did, perhaps the option refline=narrow could be useful for you in addition.

Since you design the template yourself, you don't have to use predefined values, you could set your own.

Example:

\documentclass[refline=narrow]{scrlttr2}
\setkomavar{yourref}{Z7H88}
\setkomavar{yourmail}{10/28/2011}
\setkomavar{myref}{A124}
\setkomavar{customer}{42}
\setkomavar{invoice}{I-2011-22}
\setkomavar{date}{11/01/2011}
\usepackage{calc}
\makeatletter
\@setplength{refvpos}{\useplength{toaddrvpos}}
\@setplength{refhpos}{\paperwidth-7cm}
\@setplength{refwidth}{3cm}
\makeatother
\begin{document}
\begin{letter}{Reader}
\opening{Dear reader,}
\closing{Yours Sincerely}
\end{letter}
\end{document}

enter image description here

Another approach

You could use

\setkomavar{location}{...}

to use the location field while designing your own reference fields block therein, not using the predefined reference fields. So you don't have to change position and width.