我在重新创建 Word 模板时遇到问题scrlayer-scrpage
也可能是geometry
KOMA 脚本文档类内的包。
我的模板在整个文档中有一个固定的页眉和一个页脚,但只在第一页。通常,这没有问题。然而,在原始模板中,第一页页脚占用的空间被添加到后续页面的文本区域。所以我需要includefoot=true
在geometry
第一页的定义和includefoot=false
所有后续页面中都添加类似的东西。
我希望下面的图片能够解释我想要实现的目标。当前状态:左侧,第一页有页脚。右侧,第二页有空白页脚所在的所有空白区域。
我想为从第 2 页到末尾的每一页添加页脚空间,如右图所示:
不幸的是,我只实现了第 2 页及以后的预期结果,includefoot=false
这弄乱了第一页的页脚。我尝试newgeometry
在标题部分之后使用,但正如此主题这适用于整页,我的第一部分被移到了第二页。我不想这样。
是否有可能在不跳转到新页面的情况下切换几何定义或采取其他任何措施来解决我的问题?
平均能量损失
\documentclass[listof=totoc,bibliography=totoc,parskip=half-,11pt]{scrartcl}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Preamble %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---------------------------
% Packages
% ---------------------------
\usepackage{anyfontsize}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{coffee4}
\usepackage{geometry}
\usepackage{tabularx}
\usepackage[autooneside]{scrlayer-scrpage}
% Page geometry
\geometry{
left=25mm,
right=20mm,
top=25mm,
bottom=12mm,
includefoot=true,
headsep = \dimexpr2\baselineskip\relax,
footskip = \dimexpr1\baselineskip+1.5mm\relax,
}
% ---------------------------
% Template adjustments
% ---------------------------
% Title
\makeatletter
\def\@maketitle{%
\newpage
% Zweck
\begingroup%
\normalsize%
\bfseries%
Test
\par
\endgroup%
% Abstand
\vskip 2\baselineskip
% Authors
\begingroup%
\normalsize%
\bfseries%
\begin{tabularx}{\linewidth}{@{}X}%
\@author
\end{tabularx}
\par
\endgroup%
% Abstand
\vskip 1\baselineskip
% Title
\begingroup%
\normalsize
\bfseries
\@title%
\par%
\endgroup%
% Abstand
\vskip 1\baselineskip
\rule{\textwidth}{0.4pt}%
%\vskip 1.5em%
\vskip 1\baselineskip
% Beschreibung des Vorhabens
\begingroup%
\normalsize
\bfseries
Schalala
\par%
\endgroup%
\vskip 2\baselineskip
}
\makeatother
% Font sizes
\setkomafont{section}{\normalsize\bfseries}
\setkomafont{subsection}{\normalsize\bfseries}
\setkomafont{subsubsection}{\normalsize\bfseries}
\setkomafont{paragraph}{\normalsize\bfseries}
\setkomafont{subparagraph}{\normalsize\bfseries}
% ---------------------------
% Header/Footer commands
% ---------------------------
% Clear old headers/footers
\clearpairofpagestyles
% Fonts for headers/footers
\setkomafont{pageheadfoot}{\sffamily\footnotesize}
\setkomafont{pagehead}{\sffamily}
\setkomafont{pagination}{}
% Trennlinien fuer Kopf und Fuss
\KOMAoptions{
headsepline = false,
footsepline = false,
plainfootsepline = false,
}
% Create new header for title page
\newpairofpagestyles{firstpage}{%
\ihead{Inner head}
\ohead{Outer head}
\ifoot{
\begin{tabular}[t]{@{}l}
\textbf{An organization}\\
With an address\\
and communication channels
\end{tabular}
}
\cfoot{Footer on 1\textsuperscript{st} page only}
\ofoot{\fontsize{37}{44}\selectfont XYZ}
}
% Page Layout for normal pages
\newpairofpagestyles{normalpage}{%
\ihead{Inner head}
\ohead{Outer head}
\ifoot{}
\ofoot{}
}
% Abstaende
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{section}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{subsection}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{subsubsection}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{paragraph}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{subparagraph}
%
\setlength{\parskip}{0cm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title and author %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Title}
\author{Author}
\date{\today}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\maketitle
\thispagestyle{firstpage}
\pagestyle{normalpage}
\section{First section}
\subsection{Subsection 1}
\Blindtext[2]
\subsection{Subsection 2}
\Blindtext[6]
\section{Second section}
\cofeAm{1}{0.85}{0}{0.25\textwidth}{-0.25\textheight} % needs \usepackage{coffee4}
\Blindtext[9]
\cofeDm{0.5}{0.2}{0}{-0.35\textwidth}{-0.4\textheight} % needs \usepackage{coffee4}
\end{document}
更新
使用@UlrikeFischer 提出的方法:
\documentclass[listof=totoc,bibliography=totoc,parskip=half-,11pt]{scrartcl}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Preamble %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---------------------------
% Packages
% ---------------------------
\usepackage{anyfontsize}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{coffee4}
\usepackage{geometry}
\usepackage{tabularx}
\usepackage[autooneside]{scrlayer-scrpage}
% Page geometry
\geometry{
left=25mm,
right=20mm,
top=25mm,
%bottom=20mm,
%includefoot=true,
bottom=12mm,
includefoot=false,
headsep = \dimexpr2\baselineskip\relax,
footskip = \dimexpr1\baselineskip+1.5mm\relax,
}
% ---------------------------
% Template adjustments
% ---------------------------
% Title
\makeatletter
\def\@maketitle{%
\newpage
% Zweck
\begingroup%
\normalsize%
\bfseries%
Test
\par
\endgroup%
% Abstand
\vskip 2\baselineskip
% Authors
\begingroup%
\normalsize%
\bfseries%
\begin{tabularx}{\linewidth}{@{}X}%
\@author
\end{tabularx}
\par
\endgroup%
% Abstand
\vskip 1\baselineskip
% Title
\begingroup%
\normalsize
\bfseries
\@title%
\par%
\endgroup%
% Abstand
\vskip 1\baselineskip
\rule{\textwidth}{0.4pt}%
%\vskip 1.5em%
\vskip 1\baselineskip
% Beschreibung des Vorhabens
\begingroup%
\normalsize
\bfseries
Schalala
\par%
\endgroup%
\vskip 2\baselineskip
}
\makeatother
% Font sizes
\setkomafont{section}{\normalsize\bfseries}
\setkomafont{subsection}{\normalsize\bfseries}
\setkomafont{subsubsection}{\normalsize\bfseries}
\setkomafont{paragraph}{\normalsize\bfseries}
\setkomafont{subparagraph}{\normalsize\bfseries}
% ---------------------------
% Header/Footer commands
% ---------------------------
% Clear old headers/footers
\clearpairofpagestyles
% Fonts for headers/footers
\setkomafont{pageheadfoot}{\sffamily\footnotesize}
\setkomafont{pagehead}{\sffamily}
\setkomafont{pagination}{}
% Trennlinien fuer Kopf und Fuss
\KOMAoptions{
headsepline = false,
footsepline = false,
plainfootsepline = false,
}
% Create new header for title page
\newpairofpagestyles{firstpage}{%
\ihead{Inner head}
\ohead{Outer head}
\ifoot{
\raisebox{1cm}[0pt][0pt]{%
\begin{tabular}[t]{@{}l}
\textbf{An organization}\\
With an address\\
and communication channels
\end{tabular}
}
}
\cfoot{
\raisebox{1cm}[0pt][0pt]{%
Footer on 1\textsuperscript{st} page only
}
}
\ofoot{
\raisebox{1cm}[0pt][0pt]{%
{\fontsize{37}{44}\selectfont XYZ}
%\normalsize
}
}
}
% Page Layout for normal pages
\newpairofpagestyles{normalpage}{%
\ihead{Inner head}
\ohead{Outer head}
\ifoot{}
\ofoot{}
}
% Abstaende
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{section}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{subsection}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{subsubsection}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{paragraph}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{subparagraph}
%
\setlength{\parskip}{0cm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title and author %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Title}
\author{Author}
\date{\today}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\maketitle
\enlargethispage{-1cm}
\thispagestyle{firstpage}
\pagestyle{normalpage}
\section{First section}
\subsection{Subsection 1}
\Blindtext[2]
\subsection{Subsection 2}
\Blindtext[6]
\section{Second section}
\Blindtext[9]
\end{document}
会发生什么情况\ofoot
?
答案1
根据您的更新,您只需将\raisebox{1cm}[0pt][0pt]
命令中的命令更改\ofoot
为例如\raisebox{0cm}[0pt][0pt]
。请注意,我将第一个参数更改1cm
为0cm
。
拥有完整的 MWE
\documentclass[%
listof=totoc,
bibliography=totoc,
parskip=half-,
11pt
]{scrartcl}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Preamble %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---------------------------
% Packages
% ---------------------------
\usepackage{anyfontsize}
\usepackage[english]{babel}
\usepackage{blindtext}
%\usepackage{coffee4}
\usepackage{geometry}
\usepackage{tabularx}
\usepackage[autooneside]{scrlayer-scrpage}
% Page geometry
\geometry{
left=25mm,
right=20mm,
top=25mm,
bottom=12mm,
includefoot=false,
headsep = \dimexpr2\baselineskip\relax,
footskip = \dimexpr1\baselineskip+1.5mm\relax,
}
% ---------------------------
% Template adjustments
% ---------------------------
% Title
\makeatletter
\def\@maketitle{%
\newpage
% Zweck
\begingroup%
\normalsize%
\bfseries%
Test
\par
\endgroup%
% Abstand
\vskip 2\baselineskip
% Authors
\begingroup%
\normalsize%
\bfseries%
\begin{tabularx}{\linewidth}{@{}X}%
\@author
\end{tabularx}
\par
\endgroup%
% Abstand
\vskip 1\baselineskip
% Title
\begingroup%
\normalsize
\bfseries
\@title%
\par%
\endgroup%
% Abstand
\vskip 1\baselineskip
\rule{\textwidth}{0.4pt}%
%\vskip 1.5em%
\vskip 1\baselineskip
% Beschreibung des Vorhabens
\begingroup%
\normalsize
\bfseries
Schalala
\par%
\endgroup%
\vskip 2\baselineskip
}
\makeatother
% Font sizes
\setkomafont{section}{\normalsize\bfseries}
\setkomafont{subsection}{\normalsize\bfseries}
\setkomafont{subsubsection}{\normalsize\bfseries}
\setkomafont{paragraph}{\normalsize\bfseries}
\setkomafont{subparagraph}{\normalsize\bfseries}
% ---------------------------
% Header/Footer commands
% ---------------------------
% Clear old headers/footers
\clearpairofpagestyles
% Fonts for headers/footers
\setkomafont{pageheadfoot}{\sffamily\footnotesize}
\setkomafont{pagehead}{\sffamily}
\setkomafont{pagination}{}
% Trennlinien fuer Kopf und Fuss
\KOMAoptions{
headsepline = false,
footsepline = false,
plainfootsepline = false,
}
% Create new header for title page
\newpairofpagestyles{firstpage}{%
\ihead{Inner head}
\ohead{Outer head}
\ifoot{
\raisebox{1cm}[0pt][0pt]{%
\begin{tabular}[t]{@{}l}
\textbf{An organization}\\
With an address\\
and communication channels
\end{tabular}
}
}
\cfoot{
\raisebox{1cm}[0pt][0pt]{%
Footer on 1\textsuperscript{st} page only
}
}
\ofoot{
\raisebox{0cm}[0pt][0pt]{% <=======================================
{\fontsize{37}{44}\selectfont XYZ}
%\normalsize
}
}
}
% Page Layout for normal pages
\newpairofpagestyles{normalpage}{%
\ihead{Inner head}
\ohead{Outer head}
\ifoot{}
\ofoot{}
}
% Abstaende
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{section}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{subsection}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{subsubsection}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{paragraph}
\RedeclareSectionCommand[
beforeskip=1\baselineskip,
afterskip=1\baselineskip
]{subparagraph}
%
\setlength{\parskip}{0cm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title and author %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Title}
\author{Author}
\date{\today}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\maketitle
\enlargethispage{-1cm}
\thispagestyle{firstpage}
\pagestyle{normalpage}
\section{First section}
\subsection{Subsection 1}
\Blindtext[2]
\subsection{Subsection 2}
\Blindtext[6]
\section{Second section}
\Blindtext[9]
\end{document}
你将得到期望的结果:
答案2
以下是另一个建议,为第一页的页脚定义一个新层:
\documentclass[listof=totoc,bibliography=totoc,11pt]{scrartcl}
\usepackage{anyfontsize}
\usepackage[english]{babel}
\usepackage{blindtext}% only for dummy text
\usepackage{showframe}% to show the page layout
\usepackage{geometry}
\usepackage{tabularx}
\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings automatically
\usepackage{xpatch}% to patch \maketitle (page style and shorten the page)
\geometry{
left=25mm,
right=20mm,
top=25mm,
bottom=12mm,
includefoot=false,
headsep = 2\baselineskip,
footskip = \dimexpr1\baselineskip+1.5mm\relax,
}
\clearpairofpagestyles
\setkomafont{pageheadfoot}{\sffamily\footnotesize}
\setkomafont{pagination}{}
\ihead{Inner head}
\ohead{Outer head}
% declare a new layer for the footer on the first page
\DeclareNewLayer[
foreground,
textarea,
contents={\vfill
\raisebox{\dimexpr\depth-\dp\strutbox\relax}{%
\makebox[0pt][l]{%
\begin{tabular}[t]{@{}l}
\textbf{An organization}\\
With an address\\
and communication channels
\end{tabular}%
}%
\makebox[\linewidth][c]{%
Footer on 1\textsuperscript{st} page only%
}%
}%
\makebox[0pt][r]{%
{\fontsize{37}{44}\selectfont XYZ}%
}%
}
]{firstpage.foot}
% declare a new page style using layer firstpage.foot
\DeclarePageStyleByLayers{firstpage}{firstpage.foot}
% add the head layers from scrheadings to page style firstpage
\ForEachLayerOfPageStyle{scrheadings}{%
\ifstrstart{#1}{scrheadings.head.}{\AddLayersToPageStyle{firstpage}{#1}}{}%
}
\RedeclareSectionCommands[
beforeskip=1\baselineskip,
afterskip=1\baselineskip,
font=\normalsize
]{section,subsection,subsubsection,paragraph,subparagraph}
\xapptocmd{\maketitle}{\enlargethispage{-5\baselineskip}\thispagestyle{firstpage}}
{}{\PatchFailed}
\title{Title}
\author{Author}
\begin{document}
\maketitle
\section{First section}
\subsection{Subsection 1}
\Blindtext[2]
\subsection{Subsection 2}
\Blindtext[6]
\section{Second section}
\Blindtext[12]
\end{document}
请注意,对于“普通”页面,scrheadings
使用默认页面样式,并且我已删除不相关的内容。
包装结果showframe
:
没有包的结果showframe
:
还可以使用附加层在第一页的页脚上方添加分隔线:
代码:
\documentclass[listof=totoc,bibliography=totoc,11pt]{scrartcl}
\usepackage{anyfontsize}
\usepackage[english]{babel}
\usepackage{blindtext}% only for dummy text
%\usepackage{showframe}% to show the page layout
\usepackage{geometry}
\usepackage{tabularx}
\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings automatically
\usepackage{xpatch}% to patch \maketitle (page style and shorten the page)
\geometry{
left=25mm,
right=20mm,
top=25mm,
bottom=12mm,
includefoot=false,
headsep = 2\baselineskip,
footskip = \dimexpr1\baselineskip+1.5mm\relax,
}
\clearpairofpagestyles
\setkomafont{pageheadfoot}{\sffamily\footnotesize}
\setkomafont{pagination}{}
\ihead{Inner head}
\ohead{Outer head}
% declare a new layer for the footer on the first page
\DeclareNewLayer[
foreground,
textarea,
contents={\vfill
\raisebox{\dimexpr\depth-\dp\strutbox\relax}{%
\makebox[0pt][l]{%
\begin{tabular}[t]{@{}l}
\textbf{An organization}\\
With an address\\
and communication channels
\end{tabular}%
}%
\makebox[\linewidth][c]{%
Footer on 1\textsuperscript{st} page only%
}%
}%
\makebox[0pt][r]{%
{\fontsize{37}{44}\selectfont XYZ}%
}%
}
]{firstpage.foot}
\DeclareNewLayer[
clone=scrheadings.foot.above.line,
textarea,
addvoffset=\textheight-4\baselineskip
]{firstpage.foot.above.line}
% declare a new page style using layer firstpage.foot
\DeclarePageStyleByLayers[oninit=\KOMAoptions{footsepline}]{firstpage}{firstpage.foot,firstpage.foot.above.line}
% add the head layers from scrheadings to page style firstpage
\ForEachLayerOfPageStyle{scrheadings}{%
\ifstrstart{#1}{scrheadings.head.}{\AddLayersToPageStyle{firstpage}{#1}}{}%
}
\RedeclareSectionCommands[
beforeskip=1\baselineskip,
afterskip=1\baselineskip,
font=\normalsize
]{section,subsection,subsubsection,paragraph,subparagraph}
\xapptocmd{\maketitle}{\enlargethispage{-5\baselineskip}\thispagestyle{firstpage}}
{}{\PatchFailed}
\title{Title}
\author{Author}
\begin{document}
\maketitle
\section{First section}
\subsection{Subsection 1}
\Blindtext[2]
\subsection{Subsection 2}
\Blindtext[6]
\section{Second section}
\Blindtext[12]
\end{document}