4

Is it possible to control the vertical space between different elements in the sender-block of scrlttr2, i.e. increase the space between the address (street + town) and the following elements (email+phone+url+...)?

\documentclass[
    fromphone=on,
    fromemail=on]{scrlttr2} 

\setkomavar{fromname}{name}      
\setkomavar{fromaddress}{street\\ town}
// CONTROL SPACE BETWEEN THESE ELEMENTS
\setkomavar{fromphone}{phone}
\setkomavar{fromemail}{mail}

\begin{document}
 \begin{letter}{name\\ street\\ town}       
  \opening{Hello}
  some text
  \end{letter}
\end{document}

1 Answer 1

2

You can do this by patching the internals of KOMA-script. You can place text as well, if you are feeling adventurous (i even used colour). But please, be sensible and don't do this.

Please be careful, too much space, and the phone number is printed in the receiver line.

\documentclass[
    fromphone=on,
fromemail=on]{scrlttr2} 

\setkomavar{fromname}{name}      
\setkomavar{fromaddress}{street\\ town}
\setkomavar{fromphone}{phone}
\setkomavar{fromemail}{mail}
\usepackage{xcolor}
\usepackage{etoolbox}
%\tracingpatches%for debugging
\makeatletter
\patchcmd{\@gen@firsthead}{\if@phone\\}{\if@phone\\[\baselineskip]}{}{}
\patchcmd{\@gen@firsthead}{\if@email\\}{\if@email\\\textcolor{blue}{You can place text}}{}{}
\makeatother

\begin{document}
\begin{letter}{name\\ street\\ town}       
    \opening{Hello}
    some text
\end{letter}
\end{document}

tobiasdietzScrlttr2

The OP Tobias Dietz made me aware (and provided an alternative solution), that the above solution does not work, if one chooses another alignment since etoolbox only replaces the first occurence of the replacement text. Package regexpatch by our respected member egreg comes to help.
To replace every occurence, use the starred variant of xpatchcmd:

\usepackage{regexpatch}
\makeatletter
%\tracingxpatches% for debugging
\xpatchcmd*{\@gen@firsthead}{\if@phone\\}{\if@phone\\[\baselineskip]}{}{}
\xpatchcmd*{\@gen@firsthead}{\if@email\\}{\if@email\\\textcolor{blue}{You can place text}}{}{}
\makeatother
2
  • If one uses the proposed solution with the option 'fromalign=right' then one has to use the package regexpatch instead of etoolbox and use the stared version of patchcmd. The reason is that the normal patchcmd only patches the first occurrences and thus does not change the code for the right aligned header. Commented Dec 17, 2014 at 11:46
  • @TobiasDiez Thanks, i never thought of that. I added it to the answer. Greetings to L from FG.
    – Johannes_B
    Commented Dec 17, 2014 at 16:12

You must log in to answer this question.

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