
現在のセクション名 + 章.セクション番号がヘッダーに表示されます。これは通常の動作です (私が望んでいる動作です)。
例:
ページにセクションがない場合、ヘッダー テキストを削除するにはどうすればよいでしょうか。次の例は、私の問題を示しています。ヘッダーは「1.0」ですが、何も表示したくありません。
例:
これが私の MWE です:
\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\fancyhead{}
\fancyhead[LE]{\makebox[2cm][r]{}{}}
\fancyhead[RO]{\rightmark\hspace*{0.2cm}\thesection}
\begin{document}
\chapter{An example chapter}
\blindtext[25]
\section{An example section}
\blindtext
\end{document}
答え1
fancyhdr
を使用することscrbook
は推奨されません。ただし、解決策は、\thesection
内で コマンドを発行することです\markright
。 は\markright
引数を 1 つしか取らないことに注意してください ( は\markboth
2 つ必要です)。
\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{%
\markright{#1\ \thesection}%
}
\fancyhf{}
\fancyhead[RO]{\rightmark}
\fancyfoot[C]{\thepage}
\begin{document}
\chapter{An example chapter}
\lipsum[1-20]
\section{An example section}
\lipsum[1-20]
\end{document}