scrlayer-scrpage:lehead 中的“第 1 章”,rohead 中的“章節標題”

scrlayer-scrpage:lehead 中的“第 1 章”,rohead 中的“章節標題”

在文檔類 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

您可以重新定義\chaptermarkand\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}

相關內容