每个人,
我正在使用这种类型的标题。我喜欢它,除了它添加了“第 # 章”这个表达,这很麻烦。我不想要这个表达,因为在我的论文的前言和致谢中写着“第 0 章”,而在结论中写着“第 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
pagestyle 花式标题定义不需要像提到的那么复杂(除非有特定的目的)。
以下是满足您要求的花式标题的简单定义:
\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}