5

I can't find the variable to set the distance between two lines in the toadress field. In my letter the lines are clearly closer to each other than in the rest of the letter.

Here is a minimal example:

\setkomavar{toname}{%
Somebody in toname
}
\setkomavar{toaddress}{%
some place in toaddress 3b\\
Code-Townname
}

the too near toaddress line

Can you see the difference between the normal distance between toname and toaddress and the second line of toaddress called Code-Townname?


you are right. I tested your file and it looks quite nice althrough i had a slight feeling (but didn't realy see it) that its a bit the same. So i played arround and found out that its a combination of fontsize > 11 and the \large variable i use in the toaddress box.

have a look to this file:

% compile with lualatex
\documentclass[%
  fontsize=12pt, % <-----Increase this value to see it more clearly
  paper=a4,
  parskip=full,
  enlargefirstpage=off,
  fromalign=right,
  fromphone=off,
  fromrule=off,
  addrfield=on,
  backaddress=off,
  foldmarks=no,
  pagenumber=false,
  refline=nodate,
]{scrlttr2}

\usepackage{lipsum}
\usepackage[british]{babel}

\addtokomafont{toname}{\large}    % <----- i added this two lines to get a larger to 
\addtokomafont{toaddress}{\large} % <----- address than the letter font has

\LoadLetterOption{DIN}
\setkomavar{fromname}{John Doe}
\setkomavar{fromaddress}{street number\\code place}
\setkomavar{location}{\usekomavar{date}}
\setkomavar{toname}{SOMEBODY in toname}
\setkomavar{toaddress}{SOME place in toaddress 3b\\CODE-Townname}

\begin{document}

\begin{letter}{}
\opening{TesT opening,}
\lipsum
\closing{mfg}
\end{letter}
\end{document}

I can decrease my fontsize to 11pt to solve it but i wold like to know if there is a value to seperate the two lines in \addtokomafont{toaddress} a bit...

  • Can you provide a minimal working example that shows the problem? – Johannes_B Dec 20 '16 at 15:57
  • 1
    The example needs to be compilable for us to reproduce the screenshot on our machine. It is possible that you have changed the font, that something in KOMA-script is broken or that something was broken in the past. – Johannes_B Dec 20 '16 at 17:38
  • Maybe there is some space added between name and address by the class, not sure, no time to look at it right now. – Johannes_B Dec 20 '16 at 17:38
4

Update

I have reported the bug to Markus Kohm, so it is already fixed in the current prerelease (v3.22.2564) of KOMA-Script. You can install this version from the KOMA-Script website.

\documentclass[
    fontsize=14pt,
    DIV=calc
    ]{scrlttr2}[2016/01/21]% needs version 3.22.2564 or newer
\usepackage{lipsum}

\addtokomafont{toname}{\large\sffamily}
\addtokomafont{toaddress}{\large}

\setkomavar{toname}{SOMEBODY in toname}
\setkomavar{toaddress}{SOME place in toaddress 3b\\CODE-Townname}

\begin{document}
\begin{letter}{}
\opening{Hey}
\end{letter}
\end{document}

Original answer

If the font of toname and toaddress should be set/changed in the same way, use the font element addressee instead:

\documentclass[
    fontsize=14pt,
    DIV=calc
    ]{scrlttr2}
\usepackage{lipsum}

\addtokomafont{addressee}{\large}% use this element instead
%\addtokomafont{toname}{\large}    % <----- i added this two lines to get a larger to 
%\addtokomafont{toaddress}{\large} % <----- address than the letter font has

\setkomavar{toname}{SOMEBODY in toname}
\setkomavar{toaddress}{SOME place in toaddress 3b\\CODE-Townname}

\begin{document}
\begin{letter}{}
\opening{Hey}
\end{letter}
\end{document}

enter image description here

Nevertheless the font elements toname and toaddress do not work as expected. As you can see in the follwing example, changing only the font element toname affects the element toaddress in the address field too:

\documentclass[
    fontsize=14pt,
    DIV=calc
    ]{scrlttr2}
\usepackage{lipsum}

\addtokomafont{toname}{\sffamily}

\setkomavar{toname}{SOMEBODY in toname}
\setkomavar{toaddress}{SOME place in toaddress 3b\\CODE-Townname}

\begin{document}
\begin{letter}{}
\opening{Hey}
\end{letter}
\end{document}

Result:

enter image description here

As a workaround for versions older than 3.22.2564 you can patch command \@addrfield to solve both problems:

\documentclass[
    fontsize=14pt,
    DIV=calc
    ]{scrlttr2}
\usepackage{lipsum}

\addtokomafont{toname}{\large\sffamily}
\addtokomafont{toaddress}{\large}

\setkomavar{toname}{SOMEBODY in toname}
\setkomavar{toaddress}{SOME place in toaddress 3b\\CODE-Townname}

\usepackage{xpatch}
\xpatchcmd{\@addrfield}
    {\usekomafont{toname}{\usekomavar{toname}\\}}
    {{\usekomafont{toname}{\usekomavar{toname}\\}}}
    {}{\PatchFailed}
\xpatchcmd{\@addrfield}
    {\usekomafont{toaddress}{\usekomavar{toaddress}}}
    {{\usekomafont{toaddress}{\usekomavar{toaddress}\endgraf}}}% copied from the fix by Markus
    {}{\PatchFailed}
\begin{document}
\begin{letter}{}
\opening{Hey}
\end{letter}
\end{document}

Result:

![enter image description here

  • i added this part: \usepackage{xpatch} \xpatchcmd{\@addrfield} {\usekomafont{toname}{\usekomavar{toname}\\}} {{\usekomafont{toname}{\usekomavar{toname}\\}}} {}{\PatchFailed} \xpatchcmd{\@addrfield} {\usekomafont{toaddress}{\usekomavar{toaddress}}} {{\usekomafont{toaddress}{\usekomavar{toaddress}\endgraf}}}% copied from the fix by Markus {}{\PatchFailed} That works great. Thanks! – novski Dec 22 '16 at 13:47
1

Adding \struts help with spreading contents and providing a consistent baseline:

\setkomavar{toaddress}{\strut SOME place in toaddress 3b\\ \strut CODE-Townname}

enter image description here

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.