I have a long backaddress and want it to be displayed correctly in the addressee box. I have searched a lot and don't know, if there is a DIN for this too. I am wondering if noone else has ever had the problem of a long backaddress, but I haven't found anything about it.

My problem: I have a long backaddress to display. If I use the (default) KOMA option backaddress=underlined, the backaddress runs out of the addressee box. If I use backaddress=plain it seems to work. However I would like a line between backaddress and toaddress similar to the first option.

backaddress=plain:

backaddress=underlined:

Source:

\documentclass[
foldmarks=off,
%fromrule=below, % not the line I am looking for
parskip=half, % paragraph formatting
draft
]{scrlttr2}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc} % Inputencoding
\usepackage[T1]{fontenc} % Fontencoding: 7bit -> 8bit
\usepackage{lmodern}
\usepackage{graphicx} % for \scalebox
\usepackage{blindtext} % blindtext for MWE

% make signature left-aligned
\makeatletter
\renewcommand*{\raggedsignature}{\raggedright}
\makeatother

% change pagenumbering "Page X" -> "-X-"
\renewcommand\pagemark{\usekomafont{pagenumber}--\ \thepage\ --}

% change pagestyle of first page % http://tex.stackexchange.com/questions/298966/pagestyle-of-koma-letter-package
\usepackage{xpatch}

% use a small bullet as separator in the addressee for backaddress
\setkomavar{backaddressseparator}{~{$\vcenter{\hbox{\scalebox{0.5}{$\bullet$}}}$} }

\makeatletter
% spacing between \closing and signature
\setlength{\@tempskipa}{-1\baselineskip}%

% spacing between top border and firstheader
\setlength{\@tempskipa}{\baselineskip}%

% MWE: increase size of backaddress field in addressee (window of envelope) to make it fit there
\setlength{\@tempskipa}{2\baselineskip}%

\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\setkomavar{fromname}{A long, long name for backaddress}
which is quite long too\\
last line}
\setkomavar{signature}{Another long name for the signature}

\setkomavar{place}{Home}

\setkomavar{subject}{Very important subject for the MWE}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{letter}{%

\opening{Dear xy,}

\blindtext

\vspace{2\baselineskip}
\closing{\hspace{3em}Kind regards,}

\end{letter}

\end{document}


So my idea was to edit the addressee field, which is included in the \opening macro.

The definition in scrlttr2.cls:

\newcommand{\opening}[1]{%
\@PapersizeWarning
\@mkboth{\scr@fromname@var}{\scr@subject@var}%
\thispagestyle{empty}\noindent
\ifdim\useplength{subjectvpos}=\z@\else\@subjfield\fi
\@datefield
\@makelettertitle
\ifdim\useplength{subjectvpos}=\z@\if@subjafter\else\@subjfield\fi\fi
{\setparsizes{\z@}{\z@}{\z@ plus 1fil}\par@updaterelative#1\par}%
{\setlength{\@tempdima}{\baselineskip}%
\ifdim \@tempdima>\z@\vskip\@tempdima\fi}%
\ifdim\useplength{subjectvpos}=\z@\if@subjafter\@subjfield\fi\fi
}


For the addressee field one has to look at \@addrfield. This definition is way longer and looks complicated to me. I am not sure how to investigate further. Is it useful to go this way? I am currently "reverse engineering" using \renewcommand. Any better suggestions?

I have a feeling that the \baselineskip in the backaddress isn't reduced even though it's footnotesize. Is this correct (typographically)? How to change it?

Thank you for your help and merry christmas ;)

There is not only a KOMA-Script option backaddress for the switch between underlined and plain but also a KOMA-Script variable backaddress. Normally it uses the contents of the variables fromname and fromaddresse. You could change its contents and use a shorter version of the address aa backaddress.

\setkomavar{backaddress}{short from name\\short from address}


Result:

If you really want to use a multiline backoddress you have to note that default value underline for option backaddress uses command \underline. This command does not allow a linebreak in its argument. So you have to use something like a \parbox to insert an underlined multiline backaddress.

You could package varwidth (the backaddress could be shorter than the width of the addressfield) and change the KOMA-Script variable backaddress to

% use varwidth for the backaddress
\makeatletter
\end{varwidth}%
}
\makeatother


Code:

\documentclass[
foldmarks=off,
%fromrule=below, % not the line I am looking for
parskip=half, % paragraph formatting
%draft
]{scrlttr2}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc} % Inputencoding
\usepackage[T1]{fontenc} % Fontencoding: 7bit -> 8bit
\usepackage{lmodern}
\usepackage{graphicx} % for \scalebox
\usepackage{blindtext} % blindtext for MWE

% make signature left-aligned
\renewcommand*{\raggedsignature}{\raggedright}
% change pagenumbering "Page X" -> "-X-"
\renewcommand\pagemark{\usekomafont{pagenumber}--\ \thepage\ --}
% change pagestyle of first page % http://tex.stackexchange.com/questions/298966/pagestyle-of-koma-letter-package
\usepackage{xpatch}

% use a small bullet as separator in the addressee for backaddress
\setkomavar{backaddressseparator}{~{$\vcenter{\hbox{\scalebox{0.5}{$\bullet$}}}$} }
% use varwidth for the backaddress
\makeatletter
\end{varwidth}%
}
\makeatother

\makeatletter
% spacing between \closing and signature
% spacing between top border and firstheader
% MWE: increase size of backaddress field in addressee (window of envelope) to make it fit there

\makeatother

\begin{document}
\setkomavar{fromname}{A long, long name for backaddress}
which is quite long too\\
last line%
}
\setkomavar{signature}{Another long name for the signature}
\setkomavar{place}{Home}
\setkomavar{subject}{Very important subject for the MWE}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{letter}{%

\opening{Dear xy,}
\blindtext
\vspace{2\baselineskip}
\closing{\hspace{3em}Kind regards,}
\end{letter}
\end{document}

• Ah, I think I get the trick: You use a varwidth box instead of the text itself. Then this is displayed and afterwards the default underlined option takes effect - that's why there is this line. Correct so far? I didn't know, that backaddress is displayed in this case, just thought of it as as switch. I assume this works, because it is redefined depending on the passed argument (e.g. plain)? What's the difference between these two backaddresses?
– nox
Dec 25, 2016 at 23:54
• There is a difference between the KOMA-Script option backaddress and the KOMA-Script variable `backaddress*. See my updated answer.
– esdd
Dec 26, 2016 at 7:08
• Wow, great work! I wasn't aware of this. Thank you :)
– nox
Dec 26, 2016 at 17:10