
我的問題很簡單。使用以下程式碼,我僅在偶數頁的頁碼上方新增一行。另外,對於某些頁面,例如標題中的內容,我在右側和左側都有章節名稱(本例中的內容),如圖所示:。在這個頁面中,因為是偶數,所以我在頁碼上方有一行。
這是代碼:
\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}}