\documentclass{scrartcl}
\usepackage{scrletter}
\usepackage{scrlayer-scrpage}
\ofoot{A}
\pagestyle{scrheadings}
\clearpairofpagestyles
\chead{- \thepage\ -}
\begin{document}
\begin{letter}{}
page1
\newpage
page2
\end{letter}
\end{document}
页眉和页脚似乎没有效果。可能是因为它被 scrletter 覆盖了?如果我删除了 letter 环境,定义的 pagestyle 将会生效
答案1
首先:如果结果应该是一封带有第一封信页的信件,则必须使用\opening{...}
!然后您将收到警告,因为 中的强制参数为空\begin{letter}{}
。要避免此警告,请使用\begin{letter}[addrfield=false]{}
if 没有收件人。
这信件的第二页、第三页等使用保存的页面样式\letterpagestyle
。默认情况下,这是plain.letter
。您可以重新定义两种样式plain.letter
,并letter
通过
\renewpairofpagestyles{letter}{%
\clearpairofpagestyles%
\ofoot*{A}
\chead*{\pagemark}
}
例子:
\documentclass{scrartcl}
\usepackage{blindtext}% only for dummy text
\usepackage{scrletter}% loads scrlayer-scrpage and sets page style scrheadings automatically
\renewpairofpagestyles{letter}{%
\clearpairofpagestyles%
\ofoot*{A}
\chead*{\pagemark}
}
\renewcommand*\pagemark{\usekomafont{pagenumber}{- \thepage{} -}}
\let\letterpagemark\pagemark
\setkomavar{fromname}{Max Mustermann}
\begin{document}
\begin{letter}[addrfield=false]{}%<- option addrfield=false added, because there is no recipient given
\opening{Hello}% <- added!!
\Blindtext
\closing{Bye}
\end{letter}
\end{document}
或者,您可以\letterpagestyle
在序言中重新定义为您选择的页面样式。如果\letterpagestyle
为空,则文档的页面样式也将用于这些页面。
\documentclass{scrartcl}
\usepackage{blindtext}% only for dummy text
\usepackage{scrletter}% loads scrlayer-scrpage and sets page style scrheadings automatically
\clearpairofpagestyles
\ofoot{A}
\chead{\pagemark}
\renewcommand*\pagemark{\usekomafont{pagenumber}{- \thepage{} -}}
\let\letterpagemark\pagemark
\renewcommand*{\letterpagestyle}{scrheadings}% <- page style of the second, third etc. page of the letter
\setkomavar{fromname}{Max Mustermann}
\begin{document}
\begin{letter}[addrfield=false]{}%<- option addrfield=false added, because there is no recipient given
\opening{Hello}% <- added!!
\Blindtext
\closing{Bye}
\end{letter}
\end{document}
结果和上面一样。
这第一封信页使用页面样式empty
。如果您想在首封信页面上使用其他页面样式,则必须\thispagestyle{...}
在 旁边添加\opening{...}
。如果此页面样式定义了页眉,则必须添加 KOMA 选项firsthead=false
以禁用默认的首封信页面页眉。
例子:
\documentclass{scrartcl}
\usepackage{blindtext}% only for dummy text
\usepackage{scrletter}% loads scrlayer-scrpage and sets page style scrheadings automatically
\clearpairofpagestyles
\ofoot{A}
\chead{\pagemark}
\renewcommand*\pagemark{\usekomafont{pagenumber}{- \thepage{} -}}
\let\letterpagemark\pagemark
\renewcommand*{\letterpagestyle}{scrheadings}% <- page style of the second, third etc. page of the letter
\setkomavar{fromname}{Max Mustermann}
\begin{document}
\begin{letter}[
addrfield=false,%<- option addrfield=false added, because there is no recipient given
firsthead=false% <- disable the default header of the first letter page
]{}
\opening{Hello}% <- added!!
\thispagestyle{\letterpagestyle}%<- change page style of the first letter page
\Blindtext
\closing{Bye}
\end{letter}
\end{document}