KOMA 脚本 scrlttr2 toaddress 行接近

KOMA 脚本 scrlttr2 toaddress 行接近

我找不到用于设置toadress字段中两行之间距离的变量。在我的信中,两行之间的距离明显比信中其他部分的距离要近。

这是一个简单的例子:

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

太接近地址线

toname您能看出和之间的正常距离toaddress与第二行toaddress所称的之间的区别吗Code-Townname


你说得对。我测试了你的文件,它看起来很不错,尽管我有点感觉(但没有真正看到)它有点相似。所以我玩了一下,发现它是fontsize > 11\large我在toaddress框中使用的变量的组合。

看一下这个文件:

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

我可以将字体大小减小到 11pt 来解决这个问题,但我想知道是否有一个值可以将两条线稍微分开\addtokomafont{toaddress}......

答案1

更新

我已经向 Markus Kohm 报告了此错误,因此该错误已在 KOMA-Script 的当前预发布版本 (v3.22.2564) 中得到修复。您可以从KOMA-Script 网站

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

原始答案

如果要以相同的方式设置/更改toname和的字体,请改用字体元素:toaddressaddressee

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

在此处输入图片描述

然而,字体元素tonametoaddress没有按预期工作。如您在以下示例中所见,仅更改字体元素也会影响地址字段中的toname元素:toaddress

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

结果:

在此处输入图片描述

作为一个针对 3.22.2564 之前的版本的解决方法您可以使用 patch 命令\@addrfield来解决这两个问题:

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

结果:

![在此处输入图片描述

答案2

添加\strut有助于传播内容并提供一致的基线:

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

在此处输入图片描述

相关内容