答案1
scrlayer-scrpage
这是使用KOMA-Script 包的一部分的建议。
\documentclass[a4paper,12pt,oneside, BCOR=5mm, DIV=12]{scrreprt}
\usepackage[headsepline]{scrlayer-scrpage}
\automark{chapter}
\automark*{section}
\renewcommand\sectionmarkformat{\thesection\autodot\quad}
\clearmainofpairofpagestyles
\addtokomafont{pagehead}{\normalfont}
\ihead{\rightmark}
\ohead{\pagemark}
\usepackage{lipsum}
\begin{document}
\chapter{Chapter}
\lipsum[1-13]
\section{Section One}
\lipsum[1]
\section{Section Two}
\lipsum
\end{document}
使用版本fancyhdr
:
\documentclass[a4paper,12pt,oneside, BCOR=5mm, DIV=12]{scrreprt}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]
{\markboth
{\ifnumbered{chapter}{\chapappifchapterprefix{~}\thechapter\quad}{} #1}
{\ifnumbered{chapter}{\chapappifchapterprefix{~}\thechapter\quad}{} #1}%
}
\renewcommand{\sectionmark}[1]
{\markright{\ifnumbered{section}{\thesection\quad}{}#1}}
\fancyhf{}
\fancyhead[L]{\ifstr{\rightmark}{}{\leftmark}{\rightmark}}
\fancyhead[R]{\pagemark}
\usepackage{lipsum}
\begin{document}
\chapter{Chapter}
\lipsum[1-13]
\section{Section One}
\lipsum[1]
\section{Section Two}
\lipsum
\addsec{Unnumbered Section}
\lipsum
\end{document}
结果: