我创建了我的论文,并使用此代码创建了标题。文档设置为书籍类别和单面选项。我得到了一个页面,其中左侧和右侧都是数字。相反,我会在右侧显示页码,在左侧显示章节
\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[R]{\itshape\nouppercase{\leftmark}}
\fancyhead[L]{\itshape\nouppercase{\rightmark}}
\fancyhead[L,R]{\thepage}
答案1
您正在通过以下方式定义两侧标题为页码
\fancyhead[L,R]{\thepage}
因此您将获得两边的页码。尝试以下代码:
\documentclass[oneside]{book}
\usepackage{lipsum}
\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[R]{\thepage}
\fancyhead[L]{\itshape\nouppercase{\rightmark}}
\begin{document}
\chapter{Some chapter}
\section{Some section}
\lipsum[1-10]
\section{Some other section}
\lipsum[11-20]
\end{document}