4

I have the following .lco file for the from-address:

\ProvidesFile{absender.lco}[letter-class-option file]

\RequirePackage{marvosym}
\RequirePackage[utf8]{inputenc}
\RequirePackage[ngerman]{babel}
\RequirePackage{color}

\KOMAoptions{
    foldmarks=true,
    fromalign=right,
    fromrule=false,
    footsepline=off,
    fromurl=true,
    fromemail=true,
    fromfax=false,
    fromphone=false,
    fromlogo=true    
}

\setkomavar{fromphone}[\Mobilefone~]{+99\,(9)\,99\,98\,97\,96}
\setkomavar{fromemail}[\Letter~]{musterfrau@example.nothing}
\setkomavar{fromurl}[]{www.example.nothing}
\setkomavar{backaddress}{Erika Musterfrau, Hauptstraße 12, 00000 Hauptstadt, Nimmerland}
\setkomavar{fromaddress}{Erika Musterfrau, Hauptstraße 12, 00000 Hauptstadt, Nimmerland}
\setkomavar{fromfax}[\Faxmachine~]{+49\,22\,112233}
\setkomavar{fromlogo}{\includegraphics[height=3.2cm]{square.png}}

% Optisches:
\setkomafont{fromname}{\bfseries\color{black}\LARGE}
\setkomafont{fromrule}{\color{black}}
\setkomafont{fromaddress}{\small\rmfamily\mdseries\slshape\color{black}}

\setkomafont{addressee}{\small}

\setkomavar{signature}{Erika Musterfrau}
\renewcommand*{\raggedsignature}{\raggedright}

% Definiere vertikalen Abstand vor der Unterschrift
\@setplength{sigbeforevskip}{1.8cm}
\endinput

and this is the .tex file for the letter:

\documentclass[
    absender,
    paper=a4,
    version=last,]{scrlttr2}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}

\usepackage[T1]{fontenc}
\usepackage{url}
\usepackage{graphicx}

\begin{document}

\setkomavar{myref}{201807/Q}

\setkomavar{subject}{Question}
\setkomavar{date}{\today}
\setkomavar{place}{Hauptstadt}

\begin{letter}{
    Max Mustermann\\
    Musterstraße 1\\
    12345 Musterstadt\\
    }

\opening{Sehr geehrter Herr Mustermann,}

The header is not nice. \\

Mit freundlichen Grüßen,\\

Erika Musterfrau\\

\end{letter}
\end{document}

This results in the from-adress being flush with the bottom of the blue square. However, I would like the address to be centered vertically relative to the blue square. Is this possible using an .lco file or would I have to put the from-adress in the .tex file and build a custom header using firsthead?

enter image description here

3

In your example you can use the following either in the lco file or in the document itself:

\setkomavar{firsthead}{%
  \usekomafont{fromaddress}
  \begin{tabular}[c]{@{}l}
    \usekomavar{fromlogo}
  \end{tabular}%
  \hfill
  \begin{tabular}[c]{r@{}}
    \usekomavar{fromaddress}\\
    \usekomavar*{fromemail}\usekomavar{fromemail}\\
    \usekomavar{fromurl}
  \end{tabular}%
}

Example (with some changes):

\begin{filecontents*}{absender.lco}
\ProvidesFile{absender.lco}[letter-class-option file]

\RequirePackage{marvosym}
%\RequirePackage[utf8]{inputenc}% not needed with an uptodate MiKTeX or TL2018
\RequirePackage[ngerman]{babel}
\RequirePackage{xcolor}% <- changed

% Absenderdaten
\setkomavar{fromname}{Erika Musterfrau}% <- added
\setkomavar{fromaddress}{Hauptstraße 12\\00000 Hauptstadt\\Nimmerland}% <- changed

\setkomavar{fromemail}{musterfrau@example.nothing}
\setkomavar{fromurl}{www.example.nothing}
\setkomavar{fromlogo}{\includegraphics[height=3.2cm]{square.png}}

% Separatoren und Symbole
\setkomavar{phoneseparator}[\Mobilefone]{~}
\setkomavar{emailseparator}[\Letter]{~}

% Optisches:
\setkomafont{fromaddress}{\small\rmfamily\mdseries\slshape\color{black}}
\setkomafont{addressee}{\small}

\renewcommand*{\raggedsignature}{\raggedright}

% Kopfzeile auf erster Seite
\setkomavar{firsthead}{%
  \usekomafont{fromaddress}
  \begin{tabular}[c]{@{}l}
    \usekomavar{fromlogo}
  \end{tabular}%
  \hfill
  \begin{tabular}[c]{r@{}}
    \usekomavar{fromname}, {\usekomavar[\def\\{, }]{fromaddress}}\\
    \usekomavar*{emailseparator}\usekomavar{emailseparator}\usekomavar{fromemail}\\
    \usekomavar{fromurl}
  \end{tabular}%
}

% Definiere vertikalen Abstand vor der Unterschrift
\@setplength{sigbeforevskip}{1.8cm}
\endinput
\end{filecontents*}


\documentclass[
  draft,% <- I do not have the square picture
  absender,
]{scrlttr2}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}

\usepackage[T1]{fontenc}
\usepackage{url}
\usepackage{graphicx}

\begin{document}

\setkomavar{myref}{201807/Q}

\setkomavar{subject}{Question}
\setkomavar{date}{\today}
\setkomavar{place}{Hauptstadt}

\begin{letter}{
  Max Mustermann\\
  Musterstraße 1\\
  12345 Musterstadt\\
}

\opening{Sehr geehrter Herr Mustermann,}

The header is not nice. 

\closing{Mit freundlichen Grüßen,}
\end{letter}
\end{document}

Note that there is a warning regarding headheight.

Result:

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.