这是MWE:
\documentclass[a4paper,twoside=true,11pt,openright]{book}
% packages:
\usepackage{blindtext}
\usepackage{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\fancyhf{}
\fancyhead[RO]{\rightmark}
\fancyhead[LE]{\leftmark}
\fancyfoot[RO,LE]{\thepage}
\renewcommand{\headrulewidth}{1pt}
\begin{document}
\blinddocument
\end{document}
答案1
对你的 MWE 进行两处小修改,你就完成了:
\documentclass[a4paper,twoside=true,11pt,openright]{book}
% packages:
\usepackage{blindtext}
\usepackage{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\addtolength{\headwidth}{.5cm}
\addtolength{\headwidth}{.5cm}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\fancyhf{}
\fancyhead[RO]{\rightmark}
\fancyhead[LE]{\leftmark}
\fancyfoot[RO,LE]{\thepage}
\renewcommand{\headrulewidth}{1pt}
\begin{document}
\blinddocument
\end{document}