scrlttr2 徽标相对于地址的位置

scrlttr2 徽标相对于地址的位置

我有以下发件人地址的 .lco 文件:

\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~]{[email protected]}
\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

这是该信件的 .tex 文件:

\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}

这会导致发件人地址与蓝色方块的底部齐平。但是,我希望地址相对于蓝色方块垂直居中。使用 .lco 文件可以实现这一点吗?还是我必须将发件人地址放在 .tex 文件中并使用 firsthead 构建自定义标题?

在此处输入图片描述

答案1

在您的示例中,您可以在 lco 文件或文档本身中使用以下内容:

\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}%
}

示例(有一些变化):

\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}{[email protected]}
\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}

请注意,有关于头部高度的警告。

结果:

在此处输入图片描述

相关内容