6

I have got following Swiss-like letter layout, and I want to be able to move the recipient paragraph in order to match the opening of my envelope. And I want to have the place and date slipped horizontally to be aligned with the recipient's paragraph.

I have tried quite a few things, but since I am new to LaTex, I still don't understand most of its tricks. For instance, I don't understand why, in following code, things like my name and the date are defined with \setkomavar before the \begin{document}, but the recipient's paragraph is defined inside latter document section...

How can I reach my needs ?

Thanks in advance.

\documentclass[
  SN,% lco file for swiss letters (SN 010 130))
  refline=dateleft,
  firstfoot=false,
  enlargefirstpage,
  backaddress=false,
  foldmarks=false,
  parskip=half-
  ]{scrlttr2}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[french]{babel}

\setkomavar{fromname}{John Doe}
\setkomavar{fromaddress}{My Street \\ My City \\ Suisse}
% adapter ces deux lignes :
\setkomavar{date}{Vevey, \today}
\setkomavar{subject}{Titre de la lettre}
\setkomafont{title}{\bfseries\normalsize\raggedright}

\makeatletter
  \@setplength{firstheadwidth}{\textwidth}
\makeatother

\renewcommand\raggedsignature{\raggedright}

\usepackage{blindtext}% dummy text
\begin{document}
  \begin{letter}{Compagny\\Contact person\\Street\\City}
    \opening{Dear Mr. Forexample,}
    \blindtext

    \blindtext
    \closing{Meilleures pensées}
    %\encl{enclosures} % pièces jointes
    %\cc{other recipients}
  \end{letter}
\end{document}

enter image description here

1 Answer 1

5

To visualize the positions of the address field and the reference line you can use

% visualize positions of address and refline
\LoadLetterOption{visualize}
\showfields{address,refline}

With the MWE in the question you will get

enter image description here

SN.lco sets the pseudolengths for the address field to

\@setplength{toaddrvpos}{%
  45mm}
\@setplength{toaddrhpos}{%
  -8mm}
\@setplength{toaddrwidth}{%
  90mm}
\@setplength{toaddrheight}{%
  45mm}

So the address field is 45mm from top and 8mm from left paper border. To shift the address field you can use

\@addtoplength{toaddrhpos}{<horizontal shift>}
\@addtoplength{toaddrvpos}{<vertical shift>}

and maybe

\@addtoplength{reflinevpos}{<vertical shift>}

with the same <vertical shift>.

To align the date with the address field, you have to change the pseudolength for the reference line:

\@setplength{refwidth}{\useplength{toaddrwidth}}
\@setplength{refhpos}{\paperwidth}
\@addtoplength{refhpos}{\useplength{toaddrhpos}}
\@addtoplength[-]{refhpos}{\useplength{toaddrwidth}}

Example:

\documentclass[
  SN,% lco file for swiss letters (SN 010 130))
  refline=dateleft,
  firstfoot=false,
  enlargefirstpage,
  backaddress=false,
  foldmarks=false,
  parskip=half-
  ]{scrlttr2}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[french]{babel}

\setkomavar{fromname}{John Doe}
\setkomavar{fromaddress}{My Street \\ My City \\ Suisse}
% adapter ces deux lignes :
\setkomavar{date}{Vevey, \today}
\setkomavar{subject}{Titre de la lettre}
\setkomafont{title}{\bfseries\normalsize\raggedright}

% visualize positions of address and refline
\LoadLetterOption{visualize}
\showfields{address,refline}

\makeatletter
  \@setplength{firstheadwidth}{\textwidth}

% shift address
  \@addtoplength{toaddrhpos}{-1cm}
  \@addtoplength{toaddrvpos}{-1.25cm}
  %\@addtoplength{refvpos}{-1.25cm}

% align refline with address horizentally
  \@setplength{refwidth}{\useplength{toaddrwidth}}
  \@setplength{refhpos}{\paperwidth}
  \@addtoplength{refhpos}{\useplength{toaddrhpos}}
  \@addtoplength[-]{refhpos}{\useplength{toaddrwidth}}
%
\makeatother

\renewcommand\raggedsignature{\raggedright}

\usepackage{blindtext}% dummy text
\begin{document}
  \begin{letter}{Compagny\\Contact person\\Street\\City}
    \opening{Dear Mr. Forexample,}
    \blindtext

    \blindtext
    \closing{Meilleures pensées}
  \end{letter}
\end{document}

Result:

enter image description here


KOMA-Script version 3.26 (current version is 3.25) will introduce commands \setplength and \addtoplength to replace \@setplength and \@addtoplength in the document code.


Additional remark: You can set the KOMA-Script variables like date, subject for a single letter locally. Then you have to use \setkomavar{subject}{<subject of the letter>} between\begin{letter}and\opening`.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .