我在使用包时遇到了一些问题fancyhdr
。我的目标是在书籍类中使用小写字母标题(而不是默认的大写字母),如果可能的话,我希望编写一个无论使用选项还是twoside
单侧都可以正常工作的代码。
附有简化的序言;第一页是用作封面的单页 pdf。章节是 tex 文件cap1,帽2等等,而麦比用于参考书目。
如果我只是使用命令\pagestyle{fancy}
,就会发生一件奇怪的事情:标题消失,出现一条装饰线。我尝试了其他几个命令,但都不起作用。
\documentclass[12pt, openright, twoside]{book}
\usepackage{geometry}
\geometry{letterpaper}
\usepackage{pdfpages}
\usepackage{booktabs}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
%Abstract
\usepackage{fancyhdr}
\newcommand{\fncyblank}{\fancyhf{}}
\newenvironment{abstract}%
{\cleardoublepage\fncyblank\null \vfill\begin{center}%
\bfseries \LARGE \abstractname \end{center}}%
{\vfill\null}
\begin{document}
\frontmatter
\pagenumbering{Roman}
\includepdf{firstpage}
\selectlanguage{english}%
\begin{abstract}
Test.
\end{abstract}
\tableofcontents
\mainmatter
\include{caps/cap1}
\include{caps/cap2}
\bibliography{mybib}
\bibliographystyle{plain}
\end{document}
答案1
也许下面的例子会有所帮助,但我不确定这是否是预期的结果。
\documentclass[12pt,
% oneside
]{book}
\usepackage{geometry}
\geometry{letterpaper,
headheight=15.5pt% <- as suggested by fancyhdr
}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{blindtext}% only for dummy text
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[C]{\scshape\nouppercase{\leftmark}}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0pt}% <- remove headrule
%Abstract
\newenvironment{abstract}%
{\cleardoublepage\pagestyle{empty}% <- changed to "empty"
\null\vfill
\begin{center}\bfseries \LARGE \abstractname \end{center}%
}%
{\vfill\null\clearpage}
\begin{document}
\frontmatter
\pagenumbering{Roman}
First page
\begin{abstract}
Test.
\end{abstract}
\tableofcontents
\mainmatter
\Blinddocument
\end{document}
或者根据以下评论获取更多信息:
\documentclass[12pt]{book}
\usepackage{geometry}
\geometry{letterpaper,
headheight=15.5pt% <- as suggested by fancyhdr
}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{blindtext}% only for dummy text
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[LE]{\scshape\nouppercase{\leftmark}}
\fancyhead[RO]{\scshape\nouppercase{\rightmark}}
\renewcommand{\headrulewidth}{0pt}% <- remove headrule
%Abstract
\newenvironment{abstract}%
{\cleardoublepage\pagestyle{plain}% <- changed to "plain"
\null\vfill
\begin{center}\bfseries \LARGE \abstractname \end{center}%
}%
{\vfill\null\clearpage}
\begin{document}
\frontmatter
\pagenumbering{Roman}
First page
\begin{abstract}
Test.
\end{abstract}
\tableofcontents
\mainmatter
\Blinddocument
\end{document}