scrletter/scrlttr2 页脚位置和格式

scrletter/scrlttr2 页脚位置和格式

使用scrletter,我无法获得与第一页完全相同的页脚(位置和文本)。以下是 MWE:

\documentclass[a4paper,
headlines=8.1,
headheight=3cm,
footlines=1.1,
footheight=2cm,
parskip=full,
british]{scrartcl}

\usepackage[a4paper,
%    %showframe,
rmargin=2cm,
marginparsep=0cm,
marginparwidth=0cm,
footskip=1cm,
lmargin=2cm,
bmargin=2cm,
tmargin=2cm]{geometry}

\usepackage[%
foldmarks=false,
fromalign=right,
fromrule=off,
refline=dateleft,
fromphone=false,
fromemail=true,
pagenumber=footright,
fromlogo=false]{scrletter}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[en-GB]{datetime2}
\DTMlangsetup[en-GB]{ord=raise}

\usepackage[british]{babel}
%\usepackage{showframe}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% dummy text
\usepackage{blindtext}
\usepackage{lipsum}

\usepackage[pdflang=en-GB]{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    filecolor=magenta,
    urlcolor=blue,
    %pdftitle={Overleaf Example},
    %pdfpagemode=FullScreen,
}
\clearpairofpagestyles

\renewcommand*\pagemark{\thepage of \letterlastpage}
\let\letterpagemark\pagemark
\setkomavar{firstfoot}{\raggedleft \thepage\ of \letterlastpage}
\setkomavar{nextfoot}{\usekomavar{firstfoot}}

\renewcommand*{\letterpagestyle}{scrheadings}
\rofoot{\usekomavar{nextfoot}}
\refoot{\usekomavar{nextfoot}}

\setkomavar{myref}[Internal \#]{Testref1234}
\setkomavar{date}[Date]{\today}
\setkomavar{yourref}[Your \#]{Testref5678}
\setkomavar{fromname}{A N Other}
\setkomavar{signature}{A N Other}
\renewcommand*{\raggedsignature}{\raggedright}
\setkomavar{fromaddress}{%
    Building Number\\
    Street\\
    State\\
    ZIP Code%
}

\setkomavar{backaddress}{}
\setkomavar{subject}[]{\underline{Testing letter}}
\setkomavar{subjectseparator}[]{}

\begin{document}
    \begin{letter}{%
            A. Person\\
            Someplace\\
            ZIP CODE%
        }
        \opening{test}
        \lipsum[1-4]
        
        \blindtext
        
        \lipsum[1-4]\footnote{\blindtext}
        \closing{cheers}
    \end{letter}
\end{document}

n of N第一页之后的每一页页脚中的与第一页底部边距的距离不一致。另请注意,页脚因此隐藏在长页脚中。

答案1

在您的 MWE 中,您设置了footskip=1cm(文本区域和页脚基线之间的距离)和footheight=2cm(页脚框的高度)。因此,页脚与文本区域重叠。

第一封信页面使用页面样式empty。此页面上的页眉和页脚按伪长度定位(请参阅 KOMA-Script 文档)。

在所有页面上获取相同的页脚(相同的内容和相同的位置)的可能性有一些,例如。

  • 使用第一页的伪长度来更改第二页、第三页等页面样式的页脚层的位置。
  • 使用第一页的伪长度定义一个新层,并声明一个包含该层的新层页面样式。
  • plain在首封信页面上使用页面样式。然后firstfoot=false需要选项来禁用首封信页面的默认页脚。
  • ETC。

以下是第三种可能性的两个示例:

  1. plain作为别名plain.letter
\documentclass[
  headheight=3cm,
  %footheight=2cm,% <- remove this!!
  parskip=full,
  british
]{scrartcl}

\usepackage[
margin=2cm,
marginparsep=0cm,
marginparwidth=0cm,
footskip=1cm,
]{geometry}
%\usepackage{showframe}

\usepackage[%
  foldmarks=false,
  fromalign=right,
  fromrule=off,
  refline=dateleft,
  fromphone=false,
  fromemail=true,
  backaddress=false,
  subject=underlined,
  pagenumber=footright,
  firstfoot=false% <- added!
]{scrletter}% <- loads package scrlayer-scrpage automatically

\usepackage[T1]{fontenc}
\usepackage[en-GB]{datetime2}
\DTMlangsetup[en-GB]{ord=raise}
\usepackage{babel}

\usepackage{lipsum}% dummy text

\usepackage[pdflang=en-GB]{hyperref}
\hypersetup{
  colorlinks=true,
  linkcolor=black,
  filecolor=magenta,
  urlcolor=blue
}

\renewcommand*\pagemark{\usekomafont{pagenumber}{\thepage\ of \letterlastpage}}% <- changed
\let\letterpagemark\pagemark
\AddToHook{cmd/opening/after}{\thispagestyle{plain}}% <- added

\setkomavar{myref}[Internal \#]{Testref1234}
\setkomavar{date}[Date]{\today}
\setkomavar{yourref}[Your \#]{Testref5678}
\setkomavar{fromname}{A N Other}
\setkomavar{signature}{A N Other}
\renewcommand*{\raggedsignature}{\raggedright}
\setkomavar{fromaddress}{Building Number\\Street\\State\\ZIP Code}
\setkomavar{subject}{Testing letter}

\begin{document}
\begin{letter}{A. Person\\Someplace\\ZIP CODE}
\opening{test}
\lipsum[1-9]\footnote{\lipsum[2]}
\closing{cheers}
\end{letter}
\end{document}
  1. plain作为别名plain.scrheadings
\documentclass[
  headheight=3cm,
  %footheight=2cm,% <- remove this!!
  parskip=full,
  british]{scrartcl}

\usepackage[
  margin=2cm,
  marginparsep=0cm,
  marginparwidth=0cm,
  footskip=1cm
]{geometry}
%\usepackage{showframe}

\usepackage[%
  foldmarks=false,
  fromalign=right,
  fromrule=off,
  refline=dateleft,
  fromphone=false,
  fromemail=true,
  backaddress=false,
  subject=underlined,
  pagenumber=footright,
  firstfoot=false% <- added!
]{scrletter}% <- loads package scrlayer-scrpage automatically


\usepackage[T1]{fontenc}
\usepackage[en-GB]{datetime2}
\DTMlangsetup[en-GB]{ord=raise}
\usepackage{babel}

\usepackage{lipsum}% dummy text

\usepackage[pdflang=en-GB]{hyperref}
\hypersetup{
  colorlinks=true,
  linkcolor=black,
  filecolor=magenta,
  urlcolor=blue
}

\renewcommand*\letterpagestyle{}% <- added
\clearpairofpagestyles
\ofoot*{\pagemark}% <- changed
\renewcommand*\pagemark{\usekomafont{pagenumber}{\thepage\ of \letterlastpage}}% <- changed
\let\letterpagemark\pagemark
\AddToHook{cmd/opening/after}{\thispagestyle{plain}}% <- added

\setkomavar{myref}[Internal \#]{Testref1234}
\setkomavar{date}[Date]{\today}
\setkomavar{yourref}[Your \#]{Testref5678}
\setkomavar{fromname}{A N Other}
\setkomavar{signature}{A N Other}
\renewcommand*{\raggedsignature}{\raggedright}
\setkomavar{fromaddress}{Building Number\\Street\\State\\ZIP Code}
\setkomavar{subject}{Testing letter}

\begin{document}
\begin{letter}{A. Person\\Someplace\\ZIP CODE}
\opening{test}
\lipsum[1-9]\footnote{\lipsum[2]}
\closing{cheers}
\end{letter}
\end{document}

在此处输入图片描述

如需其他建议和信息,另请参阅


更新

如果页码不能在所有页面上位于相同的垂直位置,则可以使用firstfoot=true(默认,例如删除firstfoot=false)和 KOMA-Script 变量firstfoot

\documentclass[
  headheight=3cm,
  %footheight=2cm,% <- remove this!!
  parskip=full,
  british
]{scrartcl}

\usepackage[
margin=2cm,
marginparsep=0cm,
marginparwidth=0cm,
footskip=1cm,
]{geometry}
%\usepackage{showframe}

\usepackage[%
  foldmarks=false,
  fromalign=right,
  fromrule=off,
  refline=dateleft,
  fromphone=false,
  fromemail=true,
  backaddress=false,
  subject=underlined,
  pagenumber=footright
]{scrletter}% <- loads package scrlayer-scrpage automatically

\usepackage[T1]{fontenc}
\usepackage[en-GB]{datetime2}
\DTMlangsetup[en-GB]{ord=raise}
\usepackage{babel}

\usepackage{lipsum}% dummy text

\usepackage[pdflang=en-GB]{hyperref}
\hypersetup{
  colorlinks=true,
  linkcolor=black,
  filecolor=magenta,
  urlcolor=blue
}

\renewcommand*\pagemark{\usekomafont{pagenumber}{\thepage\ of \letterlastpage}}% <- changed
\let\letterpagemark\pagemark
\setkomavar{firstfoot}{\raggedleft\pagemark}

\setkomavar{myref}[Internal \#]{Testref1234}
\setkomavar{date}[Date]{\today}
\setkomavar{yourref}[Your \#]{Testref5678}
\setkomavar{fromname}{A N Other}
\setkomavar{signature}{A N Other}
\renewcommand*{\raggedsignature}{\raggedright}
\setkomavar{fromaddress}{Building Number\\Street\\State\\ZIP Code}
\setkomavar{subject}{Testing letter}

\begin{document}
\begin{letter}{A. Person\\Someplace\\ZIP CODE}
\opening{test}
\lipsum[1-9]\footnote{\lipsum[2]}
\closing{cheers}
\end{letter}
\end{document}

答案2

感谢@esdd。但是,只有使用这些语句才是我所需要的:

\setkomavar{firstfoot}{\raggedleft \thepage\ of \letterlastpage}    
\renewcommand*\letterpagemark{\usekomafont{pagenumber}{\thepage\ of \letterlastpage}}

(2)下列内容似乎也没有用:

...
firstfoot=false
...
\clearpairofpagestyles
\AddToHook{cmd/opening/after}{\thispagestyle{plain}}

相关内容