![scrlayer-scrpage: 不同页面使用不同样式](https://linux22.com/image/316016/scrlayer-scrpage%3A%20%E4%B8%8D%E5%90%8C%E9%A1%B5%E9%9D%A2%E4%BD%BF%E7%94%A8%E4%B8%8D%E5%90%8C%E6%A0%B7%E5%BC%8F.png)
感谢这个网站,我能够获得 scrlayer-scrpage 的功能实现。
\documentclass[12pt,headsepline,footsepline,plainfootsepline,plainheadsepline]{scrreprt}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{verbose,tmargin=3.5cm,bmargin=3.5cm,lmargin=3cm,rmargin=2.5cm,headheight=33pt}
\usepackage{graphicx}
\usepackage{xcolor,calc}
\definecolor{mygreen}{RGB}{23,156,125}
\usepackage{kantlipsum}
\usepackage{scrlayer-scrpage}
\setkomafont{pageheadfoot}{\upshape}
\setkomafont{pagehead}{\slshape}
\setkomafont{headsepline}{\color{mygreen}}
\setkomafont{footsepline}{\color{mygreen}}
\pagestyle{scrheadings}
\automark{chapter}
\ihead{\leftmark\hfill \includegraphics[height=1cm]{IMG/Logo.jpg}}
\ohead{}
\chead{}
\ofoot*{\thepage}
\cfoot*{}
\chead{}
\ihead*{\leftmark\hfill \includegraphics[height=1cm]{IMG/Logo.jpg}}
\begin{document}
\chapter*{Some chapter}
\tableofcontents{}
\part{Hello}
\chapter{Some chapter}
\kant[1-10]
\end{document}
这可以按预期工作,但我想做两处更改。目录中未显示的章节“某些章节”应在页眉中显示其标题和徽标,但不显示页码。“部分”页面的页眉中应有两个徽标,而不是标题和徽标。我尝试了
\newpairofpagestyles{speciallayout}{
\ihead{\leftmark\hfill \includegraphics[height=1cm]{IMG/Logo.jpg}
\ofoot{}
\ofoot*{}}
但这不起作用。
提前致谢
乔恩
答案1
注意,无星号版本\ihead
只设置主页样式的内容,而带星号版本则同时设置两者。如果它们的参数相同,则无需同时使用两者。
在章节的第一页上,使用plain
当前的样式。因此,您可以定义pairofpagestyles
\newpairofpagestyles[scrheadings]{specialchapter}{\ofoot*{}}
然后,该对页面样式是带有空外部页脚specialchapter
的子项。scrheadings
要获取页眉中但不在目录中的未编号章节标题,请使用选项headings=optiontoheadandtoc
并\addchap[tocentry={}]{Some chapter}
改用\chapter*{Some chapter}
。
此外,您还可以通过以下方式定义部分页面的页面样式:
\newpairofpagestyles[scrheadings]{part}{%
\ihead*{\includegraphics[height=1cm]{IMG/Logo.jpg}\hfill\includegraphics[height=1cm]{IMG/Logo.jpg}}%
}
\renewcommand\partpagestyle{part}
代码:
\documentclass[12pt,headsepline,footsepline,plainfootsepline,plainheadsepline,
headings=optiontoheadandtoc% <- added
]{scrreprt}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{verbose,tmargin=3.5cm,bmargin=3.5cm,lmargin=3cm,rmargin=2.5cm,headheight=33pt}
\usepackage[demo]{graphicx}
\usepackage{xcolor,calc}
\definecolor{mygreen}{RGB}{23,156,125}
\usepackage{kantlipsum}
\usepackage[automark]{scrlayer-scrpage}
\clearpairofpagestyles
\ihead*{\leftmark\hfill \includegraphics[height=1cm]{IMG/Logo.jpg}}
\ofoot*{\pagemark}
%\ifoot*{\currentpagestyle}% only to show which page style is active
\setkomafont{pageheadfoot}{\upshape}
\setkomafont{pagehead}{\slshape}
\setkomafont{headsepline}{\color{mygreen}}
\setkomafont{footsepline}{\color{mygreen}}
\newpairofpagestyles[scrheadings]{specialchapter}{\ofoot*{}}
\newpairofpagestyles[scrheadings]{part}{%
\ihead*{\includegraphics[height=1cm]{IMG/Logo.jpg}\hfill\includegraphics[height=1cm]{IMG/Logo.jpg}}%
}
\renewcommand\partpagestyle{part}
\begin{document}
\pagestyle{specialchapter}
\addchap[tocentry={}]{Some chapter}
\cleardoublepage
\pagestyle{scrheadings}
\tableofcontents{}
\part{Hello}
\chapter{Some chapter}
\kant[1-10]
\end{document}