
みんな、
私はこのタイプのヘッダーを使用しています。気に入っているのですが、'Chapter #.' という表現が追加されるのが厄介です。この表現は不要です。なぜなら、私の論文の序文と謝辞には 'Chapter 0.' と書かれており、結論には 'Chapter 3.' と書かれているからです。ただし、このセクションは実際には章ではありません。この表現を取り除く方法はありますか?
\documentclass[12pt, letterpaper, twoside, openright]{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{fancyhdr}
\pagestyle{fancy}
\makeatletter
\DeclareRobustCommand{\format@sec@number}[2]{{\normalfont\upshape#1}#2}
\renewcommand{\chaptermark}[1]{%
\markboth{\format@sec@number{\ifnum\c@secnumdepth>\m@ne\@chapapp\ \thechapter. \fi}{#1}}{}}
\renewcommand{\sectionmark}[1]{%
\markright{\format@sec@number{\ifnum\c@secnumdepth>\z@\thesection. \fi}{#1}}}
\makeatother
\fancyhf{}
\fancyhead[RE]{\itshape\nouppercase{\leftmark}}
\fancyhead[LO]{\itshape\nouppercase{\rightmark}}
\fancyhead[LE,RO]{\thepage}
%\renewcommand{\headrulewidth}{1pt}
\begin{document}
\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\end{document}
ありがとう!
答え1
titleps
以下は、titlesec のパッケージ コンパニオンを使用した、はるかにシンプルなコードです。
\documentclass{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{titleps}
\newpagestyle{custom}{%
\headrule\setheadrule{1pt}
\sethead[\thepage][][\thechapter.~\itshape\chaptertitle]{\thesection~\itshape\sectiontitle}{}{\thepage}%
\setfoot{}{}{}
}
\pagestyle{custom}
\begin{document}
\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\end{document}
答え2
ページスタイルのファンシー ヘッダー定義は、前述のようにそれほど複雑である必要はありません (特定の目的がない限り)。
要件を満たすファンシー ヘッダーの簡単な定義は次のとおりです。
\documentclass[12pt, letterpaper, twoside, openright]{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{FancyStyle}{
\fancyhead{}
\fancyhead[RE]{\itshape\nouppercase{\leftmark}}
\fancyhead[LO]{\itshape\nouppercase{\rightmark}}
\fancyhead[LE,RO]{\thepage}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter. {##1}}}{}}
}
\begin{document}
\pagestyle{FancyStyle}
\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\end{document}