这是我的 MWE:
\documentclass[%
DIV=12, % division factor
headsepline=0.8pt, % header line
footsepline=0.4pt, % footer line
numbers=noenddot, % no dots at the end of section numbering
]{scrartcl} % 11pt, a4paper (default)
\usepackage[automark]{scrlayer-scrpage} % KOMA-Script package for headers, footers, pagestyles
\usepackage{setspace}\setdisplayskipstretch{} % For spacing
\usepackage[english]{babel} % Multilingual support
\usepackage[babel]{microtype} % Microtypography
\usepackage{xpatch} % For patching commands
\usepackage{lipsum} % For placeholder texts
% Replace \autodot with for "." \section headings
\xpretocmd{\sectionformat}{\def\autodot{.}}{}{\cfPatchFailed} % For headings
% Headers
\renewcommand{\sectionmarkformat}{\thesection.\enskip} % Add period after section number in the header
\automark[section]{section}
\automark*[subsection]{subsection}
% Shift the footer down
\ModifyLayer[addvoffset=.6ex]{scrheadings.foot.oneside}
\ModifyLayer[addvoffset=.6ex]{plain.scrheadings.foot.oneside}
% Footers
\addtokomafont{pagenumber}{\normalsize\sffamily} % page number font
\ifoot*{} % inner footer
\cfoot*{\pagemark} % central footer
\ofoot*{} % outer footer
% Footnote rule
\setfootnoterule[0.4pt]{\textwidth}
% Footnotes
\deffootnote{0.5em}{0em}{\makebox[0.5em][l]{\textsuperscript{\thefootnotemark}}}
% Page styles
\pagestyle{scrheadings}
\begin{document}
\onehalfspacing
\KOMAoptions{DIV=current}
\section{Section}
\subsection{Subsection}
\lipsum[1-9]\footnote{\lipsum[1][1-10]}
\end{document}
这是我的 MWE 的第 2 页:
这是我希望的第 2 页的结果:
我想要做的是,当当前页面在 KOMA-Script 类中包含脚注时,将其本地设置footsepline
为相等。我该如何实现?0pt
谢谢。
答案1
我认为,仅仅因为脚注而删除脚注分隔线是没有意义的。然而,主要问题是确定脚注是打印的还是注释的。下面我将使用一个技巧来实现这一点。只有当\footnoterule
此页面有脚注时,才会打印。在本例中,我使用以下方法添加标签:
\xapptocmd{\footnoterule}{\label{footrule\thepage}}{}{\PatchFailure}
scrlayer-scrpage
现在,我可以修补用于打印规则的内部命令,仅在标签未知时打印它:
\xpatchcmd\sls@hf@rule{\begingroup}{%
\@tempswatrue
\Ifstr{#1}{footsep}{%
\ifcsname r@footrule\thepage\endcsname\@tempswafalse\fi
}{}%
\if@tempswa\begingroup
}{}{\PatchFailed}
\xpatchcmd\sls@hf@rule{\endgroup}{%
\endgroup\fi
}{}{\PatchFailed}
注意:因为我正在修补一个内部命令,所以这可能会失败,内部会发生scrlayer-scrpage
改变。
\documentclass[%
DIV=12, % division factor
headsepline=0.8pt, % header line
footsepline=0.4pt, % footer line
numbers=noenddot, % no dots at the end of section numbering
]{scrartcl} % 11pt, a4paper (default)
\usepackage[automark]{scrlayer-scrpage} % KOMA-Script package for headers, footers, pagestyles
\usepackage{setspace}\setdisplayskipstretch{} % For spacing
\usepackage[english]{babel} % Multilingual support
\usepackage[babel]{microtype} % Microtypography
\usepackage{xpatch} % For patching commands
\usepackage{lipsum} % For placeholder texts
% Replace \autodot with for "." \section headings
\xpretocmd{\sectionformat}{\def\autodot{.}}{}{\cfPatchFailed} % For headings
% Headers
\renewcommand{\sectionmarkformat}{\thesection.\enskip} % Add period after section number in the header
\automark[section]{section}
\automark*[subsection]{subsection}
% Shift the footer down
\ModifyLayer[addvoffset=.6ex]{scrheadings.foot.oneside}
\ModifyLayer[addvoffset=.6ex]{plain.scrheadings.foot.oneside}
% Footers
\addtokomafont{pagenumber}{\normalsize\sffamily} % page number font
\ifoot*{} % inner footer
\cfoot*{\pagemark} % central footer
\ofoot*{} % outer footer
% Footnote rule
\setfootnoterule[0.4pt]{\textwidth}
% Footnotes
\deffootnote{0.5em}{0em}{\makebox[0.5em][l]{\textsuperscript{\thefootnotemark}}}
\usepackage{xpatch}
\xapptocmd{\footnoterule}{\label{footrule\thepage}}{}{\PatchFailed}
\makeatletter
% NOTE: Patching an internal command is always a hack and can fail in future!
\xpatchcmd\sls@hf@rule{\begingroup}{%
\@tempswatrue
\Ifstr{#1}{footsep}{%
\ifcsname r@footrule\thepage\endcsname\@tempswafalse\fi
}{}%
\if@tempswa\begingroup
}{}{\PatchFailed}
\xpatchcmd\sls@hf@rule{\endgroup}{%
\endgroup\fi
}{}{\PatchFailed}
\makeatother
\begin{document}
\onehalfspacing
\KOMAoptions{DIV=current}
\section{Section}
\subsection{Subsection}
\lipsum[1-9]\footnote{\lipsum[1][1-10]}
\end{document}
由于使用了标签,这至少需要运行两次 LaTeX。也许可以改进页面上是否有脚注的检测,使其无需标签即可工作。