使用 documentclass scrreprt 中的 scrlayer-scrpage,我希望单词“第 1 章”(或第 2 章或任何章节)出现在偶数页的外页头中,而章节标题(前面没有“第 1 章”)出现在奇数页的外页头中(见图)。编辑:在未编号的章节中,外页头应为空。我该如何实现?
我的 MWE:
\documentclass[twoside, openright, BCOR=1cm, bibliography=totoc,headsepline,chapterprefix=true]{scrreprt}
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\automark[chapter]{chapter}
\usepackage{lipsum}
\setcounter{secnumdepth}{0}
\begin{document}
\chapter{An interesting title}
\thispagestyle{empty}
\newpage
\section{A slightly less interesting title}
\lipsum[1-5]
\end{document}
答案1
问题:如果章节没有编号,偶数页的页眉应该是什么?
以下是一个建议,其中章节标题将用在未编号章节的偶数页上:
\documentclass[
twoside, open=right, BCOR=1cm,
bibliography=totoc,
headsepline,
chapterprefix=true
]{scrreprt}
\usepackage{blindtext}% only for dummy text
\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings automatically
\automark{chapter}
\renewcommand*\chaptermark[1]{%
\markboth{\ifnumbered{chapter}{\chaptermarkformat}{#1}}{#1}%
}
\begin{document}
\tableofcontents
\chapter{Numbered Chapter}
\blindtext
\section{Numbered Section}
\Blindtext[10]
\addchap{Unnumbered Chapter}
\blindtext
\addsec{Unnumbered Section}
\Blindtext[10]
\end{document}
或不带包装scrlayer-scrheadings
:
\documentclass[
twoside, open=right, BCOR=1cm,
bibliography=totoc,
headsepline,
chapterprefix=true
]{scrreprt}
\usepackage{blindtext}% only for dummy text
\pagestyle{headings}
\renewcommand*\chaptermark[1]{%
\markboth{\ifnumbered{chapter}{\chaptermarkformat}{#1}}{#1}%
}
\renewcommand*\sectionmark[1]{}
\begin{document}
\tableofcontents
\chapter{Numbered Chapter}
\blindtext
\section{Numbered Section}
\Blindtext[10]
\addchap{Unnumbered Chapter}
\blindtext
\addsec{Unnumbered Section}
\Blindtext[10]
\end{document}
如果对于未编号的章节,偶数页的页眉应为空,则可以使用
\renewcommand*\chaptermark[1]{%
\markboth{\ifnumbered{chapter}{\chaptermarkformat}{}}{#1}%
}
此外,您必须切换到手动标记并手动设置目录等的标记:
\manualmark% or option manualmark for package `scrlayer-scrpage`
\AfterTOCHead[toc]{\markboth{}{\contentsname}}
%\AfterTOCHead[lof]{\markboth{}{\listfigurename}}
%\AfterTOCHead[lot]{\markboth{}{\listfigurename}}
例子:
\documentclass[
twoside, open=right, BCOR=1cm,
bibliography=totoc,
headsepline,
chapterprefix=true
]{scrreprt}
\usepackage{blindtext}% only for dummy text
\usepackage[manualmark]{scrlayer-scrpage}% sets pagestyle scrheadings automatically
\renewcommand*\chaptermark[1]{%
\markboth{\ifnumbered{chapter}{\chaptermarkformat}{}}{#1}%
}
\AfterTOCHead[toc]{\markboth{}{\contentsname}}
%\AfterTOCHead[lof]{\markboth{}{\listfigurename}}
%\AfterTOCHead[lot]{\markboth{}{\listfigurename}}
\begin{document}
\tableofcontents
\chapter{Numbered Chapter}
\blindtext
\section{Numbered Section}
\Blindtext[10]
\addchap{Unnumbered Chapter}
\blindtext
\addsec{Unnumbered Section}
\Blindtext[10]
\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument
\end{document}
或不带包装scrlayer-scrheadings
:
\documentclass[
twoside, open=right, BCOR=1cm,
bibliography=totoc,
headsepline,
chapterprefix=true
]{scrreprt}
\usepackage{blindtext}% only for dummy text
\pagestyle{myheadings}
\renewcommand*\chaptermark[1]{%
\markboth{\ifnumbered{chapter}{\chaptermarkformat}{}}{#1}%
}
\AfterTOCHead[toc]{\markboth{}{\contentsname}}
%\AfterTOCHead[lof]{\markboth{}{\listfigurename}}
%\AfterTOCHead[lot]{\markboth{}{\listfigurename}}
\begin{document}
\tableofcontents
\chapter{Numbered Chapter}
\blindtext
\section{Numbered Section}
\Blindtext[10]
\addchap{Unnumbered Chapter}
\blindtext
\addsec{Unnumbered Section}
\Blindtext[10]
\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument
\end{document}
答案2
您可以重新定义\chaptermark
并\sectionmark
以实现这一点。
\documentclass[twoside]{scrreprt}
\usepackage{lipsum} % just for example text
\pagestyle{headings}
\renewcommand*\chaptermark[1]{%
\markboth{Chapter~\thechapter}{#1}%
}
\renewcommand*\sectionmark[1]{}
\begin{document}
\chapter{Some Title}
\lipsum[1-5]
\section{A Section}
\lipsum[6-12]
\section{Another Section}
\lipsum[13-20]
\end{document}