
ドキュメントクラス scrreprt の scrlayer-scrpage を使用して、偶数ページの外側の見出しに「Chapter 1」(または 2 などの章) という単語を表示し、奇数ページの外側の見出しに章のタイトル (その前に「Chapter 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}