![减少 scrlttr2 中标题和内容之间的空白](https://linux22.com/image/356211/%E5%87%8F%E5%B0%91%20scrlttr2%20%E4%B8%AD%E6%A0%87%E9%A2%98%E5%92%8C%E5%86%85%E5%AE%B9%E4%B9%8B%E9%97%B4%E7%9A%84%E7%A9%BA%E7%99%BD.png)
我正在使用 scrlttr2,想要减少信头和信函内容之间的空白(见图)
相应的代码如下:
\documentclass[fontsize=12pt,
paper=a4,
enlargefirstpage=on,
pagenumber=headright,
headsepline=off,
parskip=half,
fromphone=on,
fromrule=off,
fromfax=off,
fromemail=on,
fromurl=off,
fromlogo=off,
addrfield=on,
backaddress=off,
subject=beforeopening,
locfield=narrow,
foldmarks=off,
numericaldate=off,
refline=narrow]{scrlttr2}
%---------------------------------------------------------------------------
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[utf8]{inputenc}
%---------------------------------------------------------------------------
\usepackage{lmodern}
\usepackage{color}
\usepackage{marvosym}
\usepackage{ifthen}
\definecolor{firstnamecolor}{rgb}{0.65,0.65,0.65}
\definecolor{familynamecolor}{rgb}{0.45,0.45,0.45}
\definecolor{footersymbolcolor}{rgb}{0.20,0.40,0.65}
\definecolor{addresscolor}{rgb}{0.35,0.35,0.35} %grau
\newcommand*{\addressfont}{\small\sffamily\mdseries\slshape}
\newcommand{\footersymbol}{~~\color{footersymbolcolor}\normalfont\textbullet\color{addresscolor}\addressfont~~~}
%---------------------------------------------------------------------------
\setkomafont{fromname}{\sffamily \LARGE}
\setkomafont{fromaddress}{\sffamily}%% Instead of \small
\setkomafont{pagenumber}{\sffamily}
\setkomafont{subject}{\mdseries}
\setkomafont{backaddress}{\mdseries}
\usepackage{mathptmx}
%---------------------------------------------------------------------------
\begin{document}
%---------------------------------------------------------------------------
\LoadLetterOption{KOMAold}
\makeatletter
\@setplength{sigbeforevskip}{50pt}
\@setplength{firstfootvpos}{300mm} page
\@setplength{firstheadvpos}{10mm}
\@setplength{firstheadwidth}{\paperwidth}
\ifdim \useplength{toaddrhpos}>\z@
\@addtoplength[-2]{firstheadwidth}{\useplength{toaddrhpos}}
\else
\@addtoplength[2]{firstheadwidth}{\useplength{toaddrhpos}}
\fi
\@setplength{foldmarkhpos}{6.5mm}
%\@setplength{refvpos}{\useplength{toaddrvpos}}
\makeatother
%---------------------------------------------------------------------------
% Sender information
\newcommand{\myFirstname}{John}
\newcommand{\myFamilyname}{Odd}
\newcommand{\myStreet}{Street}
\newcommand{\myTown}{NY}
\newcommand{\myZipcode}{11233}
\newcommand{\myPhone}{+123 456 4879}
\newcommand{\myMail}{[email protected]}
\setkomavar{signature}{\myFirstname\ \myFamilyname}
%---------------------------------------------------------------------------
\firsthead{
\begin{flushright}
\renewcommand{\baselinestretch}{0.8}
\sffamily\mdseries\Large\color{firstnamecolor}\myFirstname\ \color{familynamecolor}\myFamilyname\\
\parbox{\textwidth}{\color{footersymbolcolor}\rule{\textwidth}{2pt}}
\normalfont\small\color{black} \myStreet \\ \myZipcode, \myTown \\ \myMail \\\myPhone
\end{flushright}
}
%---------------------------------------------------------------------------
\setkomavar{place}{\myTown}
\setkomavar{date}{\today}
%---------------------------------------------------------------------------
\setkomavar{enclseparator}{: }
%---------------------------------------------------------------------------
\pagestyle{myheadings}%% No header
\begin{letter}{International Company Coorporation\\
Mrs. Jane Doe\\
Some street 11 \\
SF, 54321}
%---------------------------------------------------------------------------
% Further options
\KOMAoptions{}
%---------------------------------------------------------------------------
\setkomavar{subject}{subject}
%---------------------------------------------------------------------------
\opening{Dear,}
text
\closing{KR}
\encl{enclosed}
\end{letter}
\end{document}
我很感谢任何提示。
答案1
如果要更改地址字段的垂直位置,请toaddrvpos
使用\@setplength
或更改伪\@addtoplength
长度。此外,您可能希望更改伪长度refvpos
以将参考线和信件内容向上移动。
也许您想使用以下值DINmtext.lco
:
\@setplength{toaddrvpos}{27mm}
\@setplength{refvpos}{80.5mm}
请注意,由于您的头部高度超出设置值,您将收到警告。
补充说明:
不要使用不同的选项两次加载同一个包。在示例中,我将使用\usepackage[utf8]{inputenc}
并删除另一行。
我将删除后面的“页面”一词\@setplength{firstfootvpos}{300mm}
。
将弃用的命令替换\firsthead{...}
为\setkomavar{firsthead}{...}.
\documentclass[fontsize=12pt,
paper=a4,
enlargefirstpage=on,
pagenumber=headright,
headsepline=off,
parskip=half,
fromphone=on,
fromrule=off,
fromfax=off,
fromemail=on,
fromurl=off,
fromlogo=off,
addrfield=on,
backaddress=off,
subject=beforeopening,
locfield=narrow,
foldmarks=off,
numericaldate=off,
refline=narrow]{scrlttr2}
%---------------------------------------------------------------------------
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%---------------------------------------------------------------------------
\usepackage{lmodern}
\usepackage{color}
\usepackage{marvosym}
\usepackage{ifthen}
\definecolor{firstnamecolor}{rgb}{0.65,0.65,0.65}
\definecolor{familynamecolor}{rgb}{0.45,0.45,0.45}
\definecolor{footersymbolcolor}{rgb}{0.20,0.40,0.65}
\definecolor{addresscolor}{rgb}{0.35,0.35,0.35} %grau
\newcommand*{\addressfont}{\small\sffamily\mdseries\slshape}
\newcommand{\footersymbol}{~~\color{footersymbolcolor}\normalfont\textbullet\color{addresscolor}\addressfont~~~}
%---------------------------------------------------------------------------
\setkomafont{fromname}{\sffamily \LARGE}
\setkomafont{fromaddress}{\sffamily}%% Instead of \small
\setkomafont{pagenumber}{\sffamily}
\setkomafont{subject}{\mdseries}
\setkomafont{backaddress}{\mdseries}
\usepackage{mathptmx}
%---------------------------------------------------------------------------
\begin{document}
%---------------------------------------------------------------------------
\LoadLetterOptions{KOMAold}
\makeatletter
\@setplength{toaddrvpos}{27mm}% <- added
\@setplength{refvpos}{80.5mm}% <- added
\@setplength{sigbeforevskip}{50pt}
\@setplength{firstfootvpos}{300mm}
\@setplength{firstheadvpos}{10mm}
\@setplength{firstheadwidth}{\paperwidth}
\ifdim \useplength{toaddrhpos}>\z@
\@addtoplength[-2]{firstheadwidth}{\useplength{toaddrhpos}}
\else
\@addtoplength[2]{firstheadwidth}{\useplength{toaddrhpos}}
\fi
\@setplength{foldmarkhpos}{6.5mm}
%\@setplength{refvpos}{\useplength{toaddrvpos}}
\makeatother
%---------------------------------------------------------------------------
% Sender information
\newcommand{\myFirstname}{John}
\newcommand{\myFamilyname}{Odd}
\newcommand{\myStreet}{Street}
\newcommand{\myTown}{NY}
\newcommand{\myZipcode}{11233}
\newcommand{\myPhone}{+123 456 4879}
\newcommand{\myMail}{[email protected]}
\setkomavar{signature}{\myFirstname\ \myFamilyname}
%---------------------------------------------------------------------------
\setkomavar{firsthead}{% <- changed
\begin{flushright}
\renewcommand{\baselinestretch}{0.8}
\sffamily\mdseries\Large\color{firstnamecolor}\myFirstname\ \color{familynamecolor}\myFamilyname\\
\parbox{\textwidth}{\color{footersymbolcolor}\rule{\textwidth}{2pt}}
\normalfont\small\color{black} \myStreet \\ \myZipcode, \myTown \\ \myMail \\\myPhone
\end{flushright}
}
%---------------------------------------------------------------------------
\setkomavar{place}{\myTown}
\setkomavar{date}{\today}
%---------------------------------------------------------------------------
\setkomavar{enclseparator}{: }
%---------------------------------------------------------------------------
\pagestyle{myheadings}%% No header
\begin{letter}{International Company Coorporation\\
Mrs. Jane Doe\\
Some street 11 \\
SF, 54321}
%---------------------------------------------------------------------------
% Further options
\KOMAoptions{}
%---------------------------------------------------------------------------
\setkomavar{subject}{subject}
%---------------------------------------------------------------------------
\opening{Dear,}
text
\closing{KR}
\encl{enclosed}
\end{letter}
\end{document}