有人可以发送此代码的示例吗?
\fancyhead[LE]{\leftmark}
\fancyhead[RO]{\rightmark}
\fancyhead[CE,CO]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
答案1
这里提供的代码作为示例:
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lipsum}
\begin{document}
% clear fancy header and footer
\fancyhf{}
% code start
\fancyhead[LE]{\leftmark}
\fancyhead[RO]{\rightmark}
\fancyhead[CE,CO]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
% code end
% set pagestyle to use fancy header and footer
\pagestyle{fancy}
% insert some text into the document
\markboth{lipsum 1}{demo 1}
\lipsum[1-3]
\markboth{lipsum 2}{demo 2}
\lipsum[4-5]
\markboth{lipsum 3}{demo 3}
\lipsum[6-8]
\markboth{lipsum 4}{demo 4}
\lipsum[9-10]
\end{document}