我的问题很简单。使用以下代码,我仅在偶数页上添加了页码行。此外,对于某些页面,例如页眉中的内容,我在右侧和左侧都添加了章节名称(在本例中为内容),如图所示:。在这一页中,由于是偶数,我在页码上方添加了一行。
这是代码:
\documentclass[a4paper,12pt,titlepage,oneside,openright]{book}
\linespread{1.5}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
%\usepackage{setspace}
\usepackage[english]{babel}
%\usepackage[babel]{csquotes}
\usepackage[write]{frontespizio}
\usepackage[acronym]{glossaries}
\usepackage[hang]{footmisc}
\usepackage[hidelinks]{hyperref}
\setlength\footnotemargin{10pt}
\usepackage{tocloft}
\usepackage{lipsum}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\usepackage[pagestyles]{titlesec}%
\newpagestyle{ruled}{%
\headrule
\sethead{}{}{\ifthechapter{\thechapter }{}\itshape\MakeUppercase{\chaptertitle}}
\footrule
\setfoot{}{\thepage}{}}
\pagestyle{ruled}
\renewpagestyle{plain}{%
\footrule
\setfoot{}{\thepage}{}}
\renewcommand{\bibname}{References}
\renewcommand{\bibname}{References}
\begin{document}
\pagenumbering{roman}
\chapter*{Acknowledgements}
\addcontentsline{toc}{chapter}{\numberline{}Acknowledgements}%
\lipsum[1-4]
\clearpage
\tableofcontents
\mainmatter
\clearpage
\chapter{Background}
\label{Background}
\lipsum[1-5]
\cleardoublepage
\addcontentsline{toc}{chapter}{\numberline{}References}%
\bibliographystyle{ieeetr}
{\footnotesize
\bibliography{mybib}}
\end{document}
答案1
titleps
以下是用代替 的解决方案fancyhdr
。请注意,我们必须\chaptermark
对未编号的章节使用命令:
\documentclass[a4paper,12pt,titlepage,oneside,openright]{book}
\linespread{1.5}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
%\usepackage{setspace}
\usepackage[english]{babel}
%\usepackage[babel]{csquotes}
\usepackage[write]{frontespizio}
\usepackage[acronym]{glossaries}
\usepackage[hang]{footmisc}
\setlength\footnotemargin{10pt}
\usepackage{tocloft}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\usepackage{titleps}%
\newpagestyle{ruled}{%
\headrule
\sethead{}{}{\itshape\MakeUppercase{\chaptertitle}}
\footrule
\setfoot{}{\thepage}{}}
\pagestyle{ruled}
\renewpagestyle{plain}{%
\footrule
\setfoot{}{\thepage}{}}
\usepackage[hidelinks]{hyperref}
\usepackage{lipsum}
\renewcommand{\bibname}{References}
\begin{document}
\pagenumbering{roman}
\chapter*{Acknowledgements}
\chaptermark{Acknowledgements}
\addcontentsline{toc}{chapter}{\numberline{}Acknowledgements}%
\lipsum[1-5]
\clearpage
\tableofcontents
\mainmatter
\clearpage
\chapter{Background}
\label{Background}
\lipsum
\cleardoublepage
\addcontentsline{toc}{chapter}{\numberline{}References}%
\bibliographystyle{ieeetr}
{\footnotesize
\bibliography{mybib}}
\end{document}
编辑要在页眉中添加章节编号(对于编号章节),您必须\usepackage[pagestyles]{titlesec}
在 的位置加载\usepackage{titleps}
,并使用
\sethead{}{}{\ifthechapter{\thechapter }{}\itshape\MakeUppercase{\chaptertitle}}