我有一个文档,我希望在一般情况下打开标题栏,但在章节中关闭它。以下 MWE 有效,但使用的选项\setheadsepline{0ex}
已被弃用。
\documentclass[a4paper,11pt,twoside]{scrbook}
\usepackage[manualmark,headsepline,footsepline]{scrlayer-scrpage}
\usepackage{blindtext}
\lehead{left even}
\cehead{center even}
\rehead{right even}
\lohead{left odd}
\cohead{center odd}
\rohead{right odd}
\newpairofpagestyles[scrheadings]{chapter}{%
\lehead*{}%
\cehead*{useless text}%
\cohead*{usefull text}%
\rohead*{}%
\setheadsepline{0ex}}
\renewcommand*\chapterpagestyle{chapter}
\begin{document}
\blinddocument
\end{document}
日志显示:
Package scrlayer-scrpage Warning: Command deprecated!
(scrlayer-scrpage) Usage of `\setheadtopline', `\setheadsepline',
(scrlayer-scrpage) `\setfootsepline', and `\setfootbotline'
(scrlayer-scrpage) became deprecated with scrlayer-scrpage.
(scrlayer-scrpage) You should use KOMA-Script options
(scrlayer-scrpage) `headsepline', `headtopline', `footsepline',
(scrlayer-scrpage) or `footbotline' with values
(scrlayer-scrpage) `<line thickness>:<line length>' to setup
(scrlayer-scrpage) the line length and thickness, and
(scrlayer-scrpage) `\setkomafont' or `\addtokomafont' to
(scrlayer-scrpage) setup the colour on input line 23.
我还在文档中发现提示,我可以使用选项headsepline=false
将其关闭以用于页面样式。但我在哪里传递该选项呢?
答案1
您可以在定义中使用 \KOMAoptions
\documentclass[a4paper,11pt,twoside]{scrbook}
\usepackage[manualmark,headsepline,footsepline]{scrlayer-scrpage}
\usepackage{blindtext}
\lehead{left even}
\cehead{center even}
\rehead{right even}
\lohead{left odd}
\cohead{center odd}
\rohead{right odd}
\newpairofpagestyles[scrheadings]{chapter}{%
\KOMAoptions{headsepline=false}%
\lehead*{}%
\cehead*{useless text}%
\cohead*{usefull text}%
\rohead*{}%
}
\renewcommand*\chapterpagestyle{chapter}
\begin{document}
\blinddocument
\end{document}
但我不确定声明新的配对页面样式是否可行。为什么不重新定义普通样式?
答案2
如果你需要目录、章节页和普通页的不同样式,你也可以使用普通样式来制作章节页
\lehead{left even}
\cehead[useless text]{center even}
\rehead*{right even}
\lohead*{left odd}
\cohead[usefull text]{center odd}
\rohead{right odd}
并通过以下方式更改目录中的页眉和页脚
\BeforeTOCHead[toc]{%
\clearpage
\KOMAoptions{plainfootsepline=false}%
\lehead[]{left even in toc}%
\cehead[]{center even in toc}%
\rehead[]{right even in toc}%
%
\lohead[]{left odd in toc}%
\cohead[]{center odd in toc}%
\rohead[right on odd toc start page]{right odd in toc}%
}
\AfterStartingTOC[toc]{\clearpage}
例子:
\documentclass[a4paper,11pt,twoside]{scrbook}
\usepackage[
manualmark,
headsepline,
footsepline,
plainfootsepline% added to get a footline on plain pages
]{scrlayer-scrpage}
\usepackage{blindtext}
\usepackage{microtype}
\lehead{left even}
\cehead[useless text]{center even}
\rehead*{right even}
\lohead*{left odd}
\cohead[usefull text]{center odd}
\rohead{right odd}
\BeforeTOCHead[toc]{%
\clearpage
\KOMAoptions{plainfootsepline=false}%
\lehead[]{left even in toc}%
\cehead[]{center even in toc}%
\rehead[]{right even in toc}%
%
\lohead[]{left odd in toc}%
\cohead[]{center odd in toc}%
\rohead[right on odd toc start page]{right odd in toc}%
}
\AfterStartingTOC[toc]{\clearpage}
\begin{document}
\addchap{Introduction}
\Blindtext
\tableofcontents
\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument
\end{document}
你也可以使用类似
\BeforeTOCHead{%
\clearpage
\KOMAoptions{automark}%
\clearpairofpagestyles
\chead[plain page in toc]{}%
\ohead{\headmark}%
\ofoot*{\pagemark}%
}
\AfterStartingTOC{\clearpage}
用于automark
TOC、LOT 和 LOF。