我正在使用一个带有主 latex 类文档的模板,该模板定义了页眉和页脚部分。我希望我的页眉分隔线为橙色,页眉本身不包含章节或页码信息。以下是代码:
\RequirePackage[markcase=used]{scrlayer-scrpage}
\providepairofpagestyles{thesisSimple}{%
\clearpairofpagestyles%
\automark[chapter]{chapter}
\ihead{\headmark}% Inner header
\ohead[\pagemark]{\pagemark}% Outer header
}
\ifoot{}% Inner footer
\ofoot{}% Outer footer
\pagestyle{thesisSimple}
\providepairofpagestyles[thesisSimple]{thesis}{%
\automark*[section]{}%
}
\providepairofpagestyles[thesisSimple]{review}{%
\ofoot[\shorttitle/\authorname]{\shorttitle/\authorname}
\ifoot[\today]{\today}
}
\pagestyle{thesis}
\ifbool{headsepline}{\KOMAoption{headsepline}{true}}{}
\PreventPackageFromLoading[\ClassError{\classname}{Package `fancyhdr' is
incompatible\MessageBreak with this class}{The pagesyles are defined
using package `scrlayer-scrpage', please consult the\MessageBreak
KOMA-script documentation for details.}]{fancyhdr}
\newcommand{\blank@p@gestyle}{empty}
\newcommand{\chapter@p@gestyle}{plain}
\NewDocumentCommand{\blankpagestyle}{ m }{%
\ClassWarning{\classname}{\string\blankpagestyle\space is
obsolete,\MessageBreak use \string\setblankpagestyle \space instead}\renewcommand{\blank@p@gestyle}{}{#1}
}
\NewDocumentCommand{\setblankpagestyle}{ m }{\renewcommand{\blank@p@gestyle}{#1}}
\NewDocumentCommand{\setchapterpagestyle}{ m }{\renewcommand{\chapter@p@gestyle}{#1}}
\DeclareDocumentCommand\cleardoublepage{}{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\thispagestyle{\blank@p@gestyle}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi%
}
答案1
不幸的是,问题中没有 MWE,并且 OP 也没有说是否应该修改一个或所有页面样式,或者是否应该定义一种新的页面样式来获得带有橙色分隔线的空标题。
修改所有图层页面样式:
\AddToLayerPageStyleOptions{@everystyle@}
{oninit=%
\KOMAoptions{headsepline,plainheadsepline}\setkomafont{headsepline}{\color{orange}}%
\ihead*{}\chead*{}\ohead*{}%
}
到修改某一层页面样式,包括相关plain
样式例如thesisSimple
:
\AddToLayerPageStyleOptions{thesisSimple}
{oninit=%
\KOMAoptions{headsepline}\setkomafont{headsepline}{\color{orange}}%
\ihead{}\chead{}\ohead{}%
}
\AddToLayerPageStyleOptions{plain.thesisSimple}
{oninit=%
\KOMAoptions{headsepline,plainheadsepline}\setkomafont{headsepline}{\color{orange}}%
\ihead*{}\chead*{}\ohead*{}%
}
定义一个新的图层页面样式:
\providepairofpagestyles{myThesis}{%
\clearpairofpagestyles
\ifoot[\currentpagestyle: inner footer]{inner footer}
\cfoot*{\pagemark}
\ofoot[outer footer]{\currentpagestyle: outer footer}
}
\AddToLayerPageStyleOptions{myThesis}
{oninit=\KOMAoptions{headsepline}\setkomafont{headsepline}{\color{orange}}}
\AddToLayerPageStyleOptions{plain.myThesis}
{oninit=\KOMAoptions{headsepline,plainheadsepline}\setkomafont{headsepline}{\color{orange}}%
}
例子:
\documentclass{book}
\usepackage{xcolor}
\usepackage[markcase=used]{scrlayer-scrpage}
\providepairofpagestyles{thesisSimple}{%
\clearpairofpagestyles%
\automark[chapter]{chapter}
\ihead{\headmark}% Inner header
\ohead[\pagemark]{\pagemark}% Outer header
}
\ifoot{}% Inner footer
\ofoot{}% Outer footer
\pagestyle{thesisSimple}
\providepairofpagestyles[thesisSimple]{thesis}{%
\automark*[section]{}%
}
\providepairofpagestyles[thesisSimple]{review}{%
\ofoot[\shorttitle/\authorname]{\shorttitle/\authorname}
\ifoot[\today]{\today}
}
\pagestyle{thesis}
\newcommand*\shorttitle{Short Title}
\newcommand*\authorname{Author Name}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% modify all layer page styles:
\AddToLayerPageStyleOptions{@everystyle@}
{oninit=%
\KOMAoptions{headsepline,plainheadsepline}\setkomafont{headsepline}{\color{orange}}%
\ihead*{}\chead*{}\ohead*{}%
}
%%%%
% or
%%%% modify one layer page style and its plain style
%\AddToLayerPageStyleOptions{thesisSimple}
%{oninit=%
%\KOMAoptions{headsepline}\setkomafont{headsepline}{\color{orange}}%
%\ihead{}\chead{}\ohead{}%
%}
%\AddToLayerPageStyleOptions{plain.thesisSimple}
%{oninit=%
%\KOMAoptions{headsepline,plainheadsepline}\setkomafont{headsepline}{\color{orange}}%
%\ihead*{}\chead*{}\ohead*{}%
%}
%%%%
% or
%%%% new pair of layer page styles:
%\providepairofpagestyles{myThesis}{%
%\clearpairofpagestyles
%\ifoot[\currentpagestyle: inner footer]{inner footer}
%\cfoot*{\pagemark}
%\ofoot[outer footer]{\currentpagestyle: outer footer}
%}
%\AddToLayerPageStyleOptions{myThesis}
%{oninit=\KOMAoptions{headsepline}\setkomafont{headsepline}{\color{orange}}}
%\AddToLayerPageStyleOptions{plain.myThesis}
%{oninit=\KOMAoptions{headsepline,plainheadsepline}\setkomafont{headsepline}{\color{orange}}%
%}
%%%%
\usepackage{blindtext}% only for dummy text
\begin{document}
\blinddocument
\cleardoublepage
\pagestyle{thesisSimple}
\blinddocument
\IfLayerPageStyleExists{myThesis}{
\cleardoublepage
\pagestyle{myThesis}
\blinddocument
}{}
\cleardoublepage
\pagestyle{review}
\blinddocument
\end{document}