如何在第二页上获取不同的 komavar{location}?

如何在第二页上获取不同的 komavar{location}?

\setkomavar{location}我想要在信件的第二页(等等)上使用不同的文字。

但好像有nextheadnextfoot其实没有nextlocation??

\documentclass{scrlttr2}
\setkomavar{location}{First Page\\ Some Text}
\begin{document}
\begin{letter}{Vorname Nachname\\Straße Nr. \\PLZ Ort}
\opening{Geehrte/r Herr/Frau}
Brieftext
\closing{Freundliche Grüße}
\encl{Dieses und Jenes}

\end{letter}
\end{document}

更新

感谢评论部分的建议,我澄清了我的例子:

\documentclass{scrlttr2}
\KOMAoptions{%
   numericaldate =true
  ,refline       =nodate
  ,backaddress   =plain
  ,parskip       =half-
}
\removereffields
\makeatletter
\AtBeginDocument{
\@setplength{refvpos}{110mm}
\@setplength{refaftervskip}{0pt}
\@setplength{toaddrhpos}{25mm}
\@setplength{firstheadhpos}{\useplength{toaddrhpos}}
\@setplength{lochpos}{15mm}
\@setplength{locvpos}{\useplength{toaddrvpos}}
\@addtoplength{locvpos}{.75\baselineskip}
\@setplength{locwidth}{45mm}
\@setplength{locheight}{232mm}
}
\makeatother
\RequirePackage{scrlayer-scrpage}
\DeclareNewLayer[
  foreground,
  textarea,
  voffset=\useplength{firstheadvpos},
  hoffset=\useplength{firstheadhpos},
  width=\useplength{firstheadwidth},
  mode=picture,
  contents=\putUL{\raisebox{\dimexpr-\height}{\usekomavar{firsthead}}\hfill\thepage}
]{likefirstpage.head}
\AddLayersToPageStyle{scrheadings}{likefirstpage.head}
\clearpairofpagestyles
\RequirePackage{geometry}
\geometry{%
   a4paper
  ,left           =25mm
  ,bottom         =16mm
  ,foot           =4mm
  ,top            =77mm
  ,nohead
  ,textwidth      =117mm
  ,marginparsep   =0mm
  ,marginparwidth =0mm
}
\setkomavar{firsthead}{My LOGO}
\setkomavar{location}{My information}
\begin{document}
\begin{letter}{Vorname Nachname\\Straße Nr. \\PLZ Ort}
\opening{Geehrte/r Herr/Frau}
Brieftext\clearpage
Second Page
\closing{Freundliche Grüße}
\encl{Dieses und Jenes}

\end{letter}
\end{document}

目前,第二页的页码位于徽标旁边。但它应该位于location第一页上设置的位置。

在此处输入图片描述

答案1

location在与第一页相同的位置声明一个新层。

\documentclass{scrlttr2}

%% to show the page layout and the position of firsthead, firstfoot, refline and location
%\LoadLetterOption{visualize}
%\showfields{head,foot,refline,address,location}
%\usepackage{showframe}

\KOMAoptions{%
  numericaldate =true
 ,refline       =nodate
 ,backaddress   =plain
 ,parskip       =half-
}
%\removereffields% not needed


\setplength{refvpos}{110mm}
\setplength{refaftervskip}{0pt}
\setplength{toaddrhpos}{25mm}
\setplength{firstheadhpos}{\useplength{toaddrhpos}}
\setplength{lochpos}{15mm}
\setplength{locvpos}{\useplength{toaddrvpos}}
\addtoplength{locvpos}{.75\baselineskip}
\setplength{locwidth}{45mm}
\setplength{locheight}{232mm}

\RequirePackage{scrlayer-scrpage}
\clearpairofpagestyles
\DeclareNewLayer[
 foreground,
 %textarea,% not needed
 voffset=\useplength{firstheadvpos},
 hoffset=\useplength{firstheadhpos},
 width=\useplength{firstheadwidth},
 mode=picture,
 contents=\putUL{\raisebox{-\height}{\usekomavar{firsthead}}}
]{likefirstpage.head}
\AddLayersToPageStyle{scrheadings}{likefirstpage.head}
\DeclareNewLayer[
 foreground,
 align=r,
 voffset=\useplength{locvpos},
 hoffset=\paperwidth-\useplength{lochpos},
 width=\useplength{locwidth},
 height=\useplength{locheight},
 contents=\usekomavar{nextlocation},
 %pretocontents=\layercontentsmeasure% to show the position of the layer
]{likefirstpage.loc}
\AddLayersToPageStyle{scrheadings}{likefirstpage.head,likefirstpage.loc}

\RequirePackage{geometry}
\geometry{%
  a4paper
 ,left           =25mm
 ,bottom         =16mm
 ,foot           =4mm
 ,top            =77mm
 ,headheight     =15pt% to avoid the scrlayer-scrpage warning, does not change the result
 %,nohead
 ,textwidth      =117mm
 ,marginparsep   =0mm
 ,marginparwidth =0mm
}
\setkomavar{firsthead}{My LOGO}
\setkomavar{location}{My information}
\newkomavar{nextlocation}
\setkomavar{nextlocation}{\pagemark}
\begin{document}
\begin{letter}{Vorname Nachname\\Straße Nr. \\PLZ Ort}
\opening{Geehrte/r Herr/Frau}
Brieftext\clearpage
Second Page
\closing{Freundliche Grüße}
\encl{Dieses und Jenes}
\end{letter}
\end{document}

结果:

在此处输入图片描述

请注意,最新版本的 KOMA-Script 也提供了\setplength\addtoplength。因此我删除了\makeatletter\makeatother

如果要显示firsthead、、和文本主体等的位置firstfoot,请使用(在 MWE 中取消注释):reflinelocation

\LoadLetterOption{visualize}
\showfields{head,foot,refline,address,location}
\usepackage{showframe}

要显示新图层的位置,请使用(在 MWE 中取消注释):

pretocontents=\layercontentsmeasure

结果:

在此处输入图片描述

相关内容